Error "ActiveX control '8856f961-340a-11d0-a96b-00c04fd705a2' cannotbe instantiated because the curr

  • Thread starter Thread starter sheperson
  • Start date Start date
S

sheperson

Hi,
I am trying to use a Web Browser control in my program. My program is
not a single thread, and I really need to use threading. When I create
a Web Browser object in the child thread, I get this error:
 
The error tells you exactly what the problem is.

Create the control in a thread that _is_ a single-threaded apartment thread.

If you're trying to use the web browser control, then you ought to have
an STA thread already.  Use that thread to create and use the control.

If you don't have an STA thread already, then you have a lot more work
to do before you can host the web browser control.

Pete

Thanks for your answer.

Here is what I am trying to do:
I have a main thread, in which I get some links. I should navigate
these links one by one, and store their data.
They must be visited one by one, in order; so I have to wait for the
process to finish.

I try to make another thread and navigate to it, using that thread and
join it until it finishes, but when I create a Web Browser control, I
get that message.
 
Is this a GUI program?  Is your main thread an STA thread?

If so, then create the web browser control on that thread.  The
navigation should not have to be synchronous, so it shouldn't be a
problem to start create the control and start the navigation from the
main thread.

If this is not a GUI program, then it's not clear to me why you are
using the ActiveX web browser control in the first place.  If all you
want is the raw data from an HTTP server, you can use HttpWebRequest to
get that.

Pete

Thanks for your reply Pete.
I solved it!
It was a GUI application, and I solved the issue by creating the
WebBrowser in the main thread.
Thanks again for your help. :D
 
im also looking for controlling webbrowser from another thread...
So if u can plz send the code...it will be helpfull
arasforever[at]gmail[dot]com
 
Back
Top