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

Why I am I getting this exception

P: n/a
Hi there,

I'm getting a "ThreadStateException" error whenever I place a particular DLL
into my app's folder. The message is:

"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. This exception is only raised if a debugger is attached to the
process."

My app is a simple forms project ('Main" is tagged with "STAThread") and the
above error occurs as soon as I call "OpenFileDialog.ShowDialog()" very
early in the life of the program. The app itself has no dependencies on this
DLL however (whatsoever). It runs fine as soon as I remove the DLL which is
only there in the first place because I want to test something (requiring me
to later invoke "Type.GetType()" for a class in this DLL). I've read about
this problem elsewhere on the web. Does anyone have any ideas. Thanks.
Jan 31 '07 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.