By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,193 Members | 1,691 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,193 IT Pros & Developers. It's quick & easy.

Copy to Clipboard problem ?

P: 1
I'm trying to copy to the clipboard a text that is read from the serial port, but when try to use:

Clipboard.SetText(MyTexo,MyText Format)

give me the follow error:

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.

Im using VB.Net 2008 and is a single form program. What could be wrong.

Regards
Jan 16 '09 #1
Share this Question
Share on Google+
1 Reply


Frinavale
Expert Mod 5K+
P: 9,731
"Using single-threaded apartments (the apartment model process) offers a message-based paradigm for dealing with multiple objects running concurrently. It enables you to write more efficient code by allowing a thread, while it waits for some time-consuming operation to complete, to allow another thread to be executed."
For more information see what MSDN has to say about Single-Threaded Apartments.

Have you tried marking the main function with the STAThreadAttribute?

-Frinny
Jan 16 '09 #2

Post your reply

Sign in to post your reply or Sign up for a free account.