G
Guest
When the following code is excuted from my .apsx page:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim test As New MyTestClass
'Create an Instance of the ClipBoard Object
Dim sHyperLink As String
Dim data_object As New System.Windows.Forms.DataObject
Dim DataFormats As System.Windows.Forms.DataFormats
Dim objClipboard As System.Windows.Forms.Clipboard
sHyperLink = test.CreateHyperlink(CInt(TextBox1.Text), TextBox2.Text)
'Write HyperLink to Clip Board
data_object.SetData(DataFormats.Html, True, sHyperLink)
objClipboard.SetDataObject(data_object, True)
End Sub
I get this error:
The current thread must set to Single Thread Apartment (STA) mode before OLE
calls can be made. Ensure that your Main function has STAThreadAttribute
marked on it.
Since I'm trying to place items on the Clients Clipboard, is there a way
around the System.Windows.Forms Namespace and still be able to use these
classes I need? If not, how do I get around the STAThreadAttribute error?
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim test As New MyTestClass
'Create an Instance of the ClipBoard Object
Dim sHyperLink As String
Dim data_object As New System.Windows.Forms.DataObject
Dim DataFormats As System.Windows.Forms.DataFormats
Dim objClipboard As System.Windows.Forms.Clipboard
sHyperLink = test.CreateHyperlink(CInt(TextBox1.Text), TextBox2.Text)
'Write HyperLink to Clip Board
data_object.SetData(DataFormats.Html, True, sHyperLink)
objClipboard.SetDataObject(data_object, True)
End Sub
I get this error:
The current thread must set to Single Thread Apartment (STA) mode before OLE
calls can be made. Ensure that your Main function has STAThreadAttribute
marked on it.
Since I'm trying to place items on the Clients Clipboard, is there a way
around the System.Windows.Forms Namespace and still be able to use these
classes I need? If not, how do I get around the STAThreadAttribute error?