Hi,
I have a winform application that is hosting a WCF Service(NamedPipes). When reciving a call a event will be triggered and then a form will be created and opened. The problem is that I get the followin exception
ActiveX control '8856f961-340a-11d0-a96b-00c04fd705a2' cannot be instantiated because the current thread is not in a single-threaded apartment.
When creating a System.Windows.Forms.WebBrowser in the winforms InitializeComponent method?
I Supose that another thread is running the even(working thread), how can I get the main thread to run the event?
I do not have any winform open at the time so I can´t use InvokeRequired.
BestRegards
Edit1 : Pleas not that I am using
[STAThread]
public static void Main(string[] args)
{
Application.Run(_instance);
}
My solution is to create a dummy winform on startup and when I need the main UI thread I will use invoke on this dummyform.
It will use some more resourse but I dont see a simpler way of doing it.