G
Guest
Just as an exercise I'm trying to write a program that will periodically read
a Web page (not mine), get some information from it, and store the
information.
It seemed the most straightforward tactic was to write a service and have
that service use an instance of WebBrowser.
The problem is that I get the following error when the thread in which the
service runs tries to instantiate the WebBrowser:
The inner exception System.Threading.ThreadStateException was thrown with
the following error message: ActiveX control
'8856f961-340a-11d0-a96b-00c04fd705a2' cannot be instantiated
because the current thread is not in a single-threaded apartment.
So, I want to set the service's thread to STA, but I don't know how to tell
the SCM to start the thread that way. If it's possible, how?
Otherwise I can probably spawn off another thread in STA mode, but that
seems a bit wasteful. I'll try it anyway while awaiting responses.
Alternatively, how might I simply pull in a Web page without using a
WebBrowser?
a Web page (not mine), get some information from it, and store the
information.
It seemed the most straightforward tactic was to write a service and have
that service use an instance of WebBrowser.
The problem is that I get the following error when the thread in which the
service runs tries to instantiate the WebBrowser:
The inner exception System.Threading.ThreadStateException was thrown with
the following error message: ActiveX control
'8856f961-340a-11d0-a96b-00c04fd705a2' cannot be instantiated
because the current thread is not in a single-threaded apartment.
So, I want to set the service's thread to STA, but I don't know how to tell
the SCM to start the thread that way. If it's possible, how?
Otherwise I can probably spawn off another thread in STA mode, but that
seems a bit wasteful. I'll try it anyway while awaiting responses.
Alternatively, how might I simply pull in a Web page without using a
WebBrowser?