473,795 Members | 2,554 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Threadin g.ThreadStateEx ception: 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..c tor(String clsid, Int32 flags)
at System.Windows. Forms.AxHost..c tor(String clsid)
at AxSHDocVw.AxWeb Browser..ctor()
at MyNamespace.MyC lass.Initialize Component()
at MyNamespace.MyC lass..ctor()
at MyServiceNamesp ace.MyService.O nStart(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 2195

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
1604
by: Charles A. Lackman | last post by:
Hello and thank you for your assistance. I have attempted to accomplish what I need using delegates with no success. i.e. //Button Click// Dim PollThread As Threading.Thread PollThread = New Threading.Thread(AddressOf PollThreadAddress) PollThread.Start() End Sub
2
14467
by: Warren | last post by:
I don't understand what's going on in the following program. I believe it should simply create a form with a browser in it and navigate that browser to Google. However, the constructor for the WebBrowser is throwing a ThreadStateException saying ActiveX control '8856f961-340a-11d0-a96b-00c04fd705a2' cannot be instantiated because the current thread is not in a single-threaded apartment. Any ideas what's going on? using System; using...
6
555
by: CK | last post by:
I have the following code in a windows service, when I start the windows service process1 and process2 work fine , but final process (3) doesnt get called. i stop and restart the windows service and the final process(3) gets called. what am I doing wrong with the threading? by the way Directory.GetFiles(IncomingXMLPath1).Length is some global outcome from process 1. Thanks 1)
0
908
by: BergRD | last post by:
For some odd reason my original post was double posted then removed from the forums. Odd happenings but wanted to re-post incase no one saw the original, thanks :D > Salutations! > > New to the forums but have gotten many an idea from lurking over the past few months but alas it's time to begin positing; posting to a problem I cannot seem to resolve. This is a long description but my hopes are the more information the better someone...
5
12249
by: Tony Gravagno | last post by:
I have a class that instantiates two Timer objects that fire at different intervals. My class can be instantiated within a Windows Form or from a Windows Service. Actions performed by one of the event handlers may take longer than the interval for either of the timers, so it's possible for multiple events to fire "simultaneously" and for events to queue up. I'm attempting to get the timers to sync on some reference type object, or use...
11
2845
by: Anil Gupte | last post by:
....and how do I insert one into my form? I used in VB 6.0 last, but cannot figure out where it is in .Net Thanx, -- Anil Gupte www.keeninc.net www.icinema.com
9
2192
by: brendan_gallagher_2001 | last post by:
Hi I am seeing some strange behaviour on a windows (vb.net 1.1) service. Basically, what I see happening is that when the Timer1_Elapsed event fires, it attempts to execute Timer1.Stop() but takes a long time to do this. In the meantime, the Timer1_Elapsed event fires again and a new thread seems to try and also tries to execute Timer1.Stop(). Eventually, both threads manage to execute Timer1.Stop() and both threads execute the...
5
1573
by: Christian Schlemmer | last post by:
Hi, in a webapplication, after a submit a page is called which is processing images uploaded by the user. currently after submit a status bar will be visible (the page for the image processing runs in an iframe) and after image processing the page makes an redirect. if there are many images, the processing needs some time and if the user is closing the browser the processing will be interrupted. now i would like to source out the...
0
3267
by: =?Utf-8?B?Q29kZVJhem9y?= | last post by:
I am converting a windows application which contains a web browser control into an ASP.net application. The Windows project references all manner of html controls in the WebBrowser control and retrieves values using the HtmlControlCollection class etc. I was hoping I was going to be able to work with the Windows.Forms.WebBrowser object from inside my ASP.net webform by simply adding a reference to System.Windows.Forms and doing code...
0
9519
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10436
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10213
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9040
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7538
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6780
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3722
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2920
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.