STAThreadAttribute
-
i am using C#.net 1.1 while using clipboard m geeting this exception System.Threading.ThreadStateException: 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. at System.Windows.Forms.Clipboard.GetDataObject()
-
i am using C#.net 1.1 while using clipboard m geeting this exception System.Threading.ThreadStateException: 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. at System.Windows.Forms.Clipboard.GetDataObject()
// [STAThreadAttribute] [STAThread] public static void Main() put that attribute in your entry point.
Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
-
// [STAThreadAttribute] [STAThread] public static void Main() put that attribute in your entry point.
Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
i have made an entry [STAThread] public static void Main() still m getting the exception
-
i have made an entry [STAThread] public static void Main() still m getting the exception
OK - well, that's how you set it. Do you set the thread model to something else, elsewhere in your code ? I don't even know if you can, but that attribute is what it's telling you to set. Have you googled the error message text ?
Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
-
OK - well, that's how you set it. Do you set the thread model to something else, elsewhere in your code ? I don't even know if you can, but that attribute is what it's telling you to set. Have you googled the error message text ?
Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
Ya i have googled but itz saying to set entry point as what u said. but i cant figure out the exception
-
i am using C#.net 1.1 while using clipboard m geeting this exception System.Threading.ThreadStateException: 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. at System.Windows.Forms.Clipboard.GetDataObject()
Are you trying to access your object from a background thread?
Deja View - the feeling that you've seen this post before.
-
Are you trying to access your object from a background thread?
Deja View - the feeling that you've seen this post before.
M trying to access Clipboard.GetDataObject(); it is throwing exception when accesing clipboard