user1823701 user1823701 - 1 year ago 93
C# Question

Error while trying to copy string to clipboard

I have tried this code:


And I get this error:

Current thread must be set to single thread apartment (STA) mode before OLE calls can be made. Ensure that your
function has
marked on it.

How can I fix it?

Answer Source

Put [STAThread] above your main method:

static void Main()
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download