G
Guest
Hi
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:\"
Else
FolderBrowserDialog1.SelectedPath = ""
End If
FolderBrowserDialog1.ShowDialog()
end sub
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 debugger is attached to the
process."
So i created a class 'clsStartup' containing a main procedure:
Public Class clsStartup
<STAThread()> _
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.
Application.Run(frmWSGWebSiteLocationUpdate)
End Sub
End Class
And set the startup object to be clsStartup.
But I still get the same message.
Can anyone help me please?
Regards,
Steve.
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:\"
Else
FolderBrowserDialog1.SelectedPath = ""
End If
FolderBrowserDialog1.ShowDialog()
end sub
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 debugger is attached to the
process."
So i created a class 'clsStartup' containing a main procedure:
Public Class clsStartup
<STAThread()> _
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.
Application.Run(frmWSGWebSiteLocationUpdate)
End Sub
End Class
And set the startup object to be clsStartup.
But I still get the same message.
Can anyone help me please?
Regards,
Steve.