I'm getting the exception 'The calling thread must be STA, because many UI components require this.' Which is stupid because the constructor that is giving the exception IS BEING CALLED FROM WITHIN A STA THREAD!
I'm really at the end of my rope. Has anyone else come across this problem?
The answer was this was somewhat annoying, but it worked.
I discovered to my immense distaste that the state of my thread directly inside my Main function was MTA despite my use the STAThread
attribute. Apparently, the debugging thread that called my entry point decided to override the attribute and make it an MTA thread. The solution was to then create another thread and run my application from within that. I did this, and it worked. I hate this, but no one else seems to have this problem.
It may be the funky way I have my project set up. That is, to be run from within an MFC application (can't be helped) targeting .Net 3.5 even though its in Visual Studio 2010.
Anyway, it works.