472,119 Members | 2,000 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,119 software developers and data experts.

Threading issues with a WebBrowser inside a Windows Service

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?
Nov 15 '05 #1
0 2129

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Charles A. Lackman | last post: by
6 posts views Thread by CK | last post: by
11 posts views Thread by Anil Gupte | last post: by
9 posts views Thread by brendan_gallagher_2001 | last post: by
5 posts views Thread by Christian Schlemmer | last post: by
reply views Thread by =?Utf-8?B?Q29kZVJhem9y?= | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.