I have just upgraded a vb.net 2003 project to 2005. I get an error when
trying to access a FolderBrowserDialog as follows
Private Sub Button1_Click_2(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
FolderBrowserDialog1.Description = "Please select a location for
your web pages."
'Default to the c drive if it exists
If Directory.Exists("c:\") = True Then
FolderBrowserDialog1.SelectedPath = "c:\"
FolderBrowserDialog1.SelectedPath = ""
The error I get is:
"the Current thread must be set to single thread apartment (STA) mode before
OLE calls can be made. Ensure that your Main function has STAThreadAttribute
marked on it. This exception is only raised if a de *** is attached to the
So i created a class 'clsStartup' containing a main procedure:
Public Class clsStartup
Shared Sub Main()
' Declare a variable named frm1 of type Form1.
Dim frm1 As frmWSGWebSiteLocationUpdate
' Instantiate (create) a new Form1 object and assign
' it to variable frm1.
frm1 = New frmWSGWebSiteLocationUpdate()
' Call the Application class' Run method
' passing it the Form1 object created above.
And set the startup object to be clsStartup.
But I still get the same message.
Can anyone help me please?