Heh, I know some of you have read the subject and are wondering what
in the heck I'm doing. Well, for all intensive purposes, I've had to
embed a WebBrowser control into a DLL and reference that DLL in a
windows service I've created.
The problem is I get the following error/stacktrace:
System.Threading.ThreadStateException: Could not instantiate ActiveX
control '8856f961-340a-11d0-a96b-00c04fd705a2' because the current
thread is not in a single-threaded apartment.
at System.Windows.Forms.AxHost..ctor(String clsid, Int32 flags)
at System.Windows.Forms.AxHost..ctor(String clsid)
at AxSHDocVw.AxWebBrowser..ctor()
at MyNamespace.MyClass.InitializeComponent()
at MyNamespace.MyClass..ctor()
at MyServiceNamespace.MyService.OnStart(String[] args)
You'll notice the error occurs while trying to create an instance of
my WebBrowser. I'm not familiar with threading, so I don't know what
this error meansr. All newgroup threads I've read told me to put the
attribute [STAThread] before my Main() function.
The attribute already exists, so that's not the issue. And that was
basically the only solution anyone ever gave. :)
Anybody have a clue?