I have an intermittent problem where I cannot create an instance of the System.Windows.Forms.Form class in my C# library. I log exceptions in my program, but unfortunately nothing was recorded for this problem. It might not be relevant, but my library, called via COM (i.e. there is no Main method).
So I threw a test exception, and it was caught and logged successfully -- so I'm thinking that maybe something screwy is going on in the message loop?
Update 1
The Form is created using the following code in a Thread
which has ApartmentState.STA
set.
someForm = new Form();
someForm.Visible = false;
someForm.Text = "Hello world!";