Clipboard.SetDataObject requires [STAThread]?

F

Fruber Malcome

I have a project that is a basic form that creates an instance of my
WordClass.

My WordClass, creates a Word.Application and Document etc. It creates /
removes commandbars and menubars.

The basic form's (application's) Main is tagged STAThread.

Whenever one of my commandbar handlers trigger, and within that handler I
call Clipboard.SetDataObject("blah") - I get an exception that says that I
need to mark the main thread with the STAThreadAttribute.

What would be considered the main thread in this instance? (my handlers?)

Exception Details:
System.Reflection.TargetInvocationException
HR=0x80131604
COMExCode=0xe0434f4d

Inner Exception:
+ InnerException {"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." } System.Exception

any help would be appreciated.

thanks - Fruber
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top