Fix Activex Control Cannot Be Instantiated Because The Current Thread (Solved)

Home > Cannot Be > Activex Control Cannot Be Instantiated Because The Current Thread

Activex Control Cannot Be Instantiated Because The Current Thread


The class I'm using is just class and the AxWebBrowser looks like it needs to be added into this.Controls(). var t = new Thread(MyThreadStartMethod); t.SetApartmentState(ApartmentState.STA); t.Start(); share|improve this answer edited Mar 30 '11 at 20:58 Factor Mystic 16k105578 answered Sep 13 '09 at 18:23 JaredPar 455k869281233 Thanks, great How to deal with a coworker that writes software to give him job security instead of solving problems? The browser window that is opened by the main form is the one that is giving me the error.

First Skills to Learn for Mountaineering How did early mathematicians make it without Set theory? Cause Defect in early versions of Controller 10.2.x. Does every interesting photograph have a story to tell? Sep 02, 2008 10:55 AM|cameron_w|LINK I've come across the same problem when using the standard web browser control to do some cross-site page scraping.

Activex Control '8856f961-340a-11d0-a96b-00c04fd705a2' Cannot Be Instantiated Because

Check this answer for the code to create a thread that runs WB. I have also found that when the program resumes it is running in a worker thread rather than the main thread. Linux questions C# questions ASP.NET questions fabric questions SQL questions discussionsforums All Message Boards... The next step will vary slightly, depending on: The operating system (of your Controller application server) If you have modified the IIS Application pool settings from their default settings.

Also, it has something to do with the thread apartment running. However, in some environments, it can be triggered by a Cognos BI timeout. Your AxSHDocVw.AxWebBrowser component is obviously a wrapper around a COM object and COM objects have to be run in STA. Webbrowser Activex Control Cannot Be Instantiated Private void YourFunc(..) { if (this.InvokeRequired) { Invoke(new MethodInvoker(delegate() { // Call your method YourFunc(..); })); } else { /// } share|improve this answer edited Dec 12 '14 at 18:55 answered

Join them; it only takes a minute: Sign up Single-threaded apartment - cannot instantiate ActiveX control up vote 45 down vote favorite 11 I need to get information about applied CSS Cannot Be Instantiated Because The Current Thread Is Not In A Single-threaded Apartment When answering a question please: Read the question carefully. to 60 minutes) then (by default) Cognos authentication's timeout is set to 3600 seconds (60 minutes). More information can be read here: Sleep(suspend) and Resuming windows form starts program on worker thread instead of main thread activex sta single-threaded apartments apartment-state share|improve this question edited May 16

Upgrade to Internet Explorer 8 or newer for a better experience. | Search MSDN Search all blogs Search this blog Sign in Kaushalendra Kaushalendra ActiveX control cannot be instantiated because the C# Task Sta c# .net webbrowser-control console-application share|improve this question edited Apr 2 '11 at 19:28 abatishchev 57.4k57215356 asked Apr 1 '11 at 21:55 sooprise 7,44841138224 If still interested, have a loop When components require a STA thread to run in then it's really just a matter of providing them with exactly that. The best bet is to create a new form. –JaredPar Sep 13 '09 at 18:46 1 Hi, the code should be t.SetApartmentState(ApartmentState.STA); –Santiago Corredoira Nov 28 '10 at 12:55 Cannot Be Instantiated Because The Current Thread Is Not In A Single-threaded Apartment

Privacy Statement| Terms of Use| Contact Us| Advertise With Us| CMS by Umbraco| Hosted on Microsoft Azure Feedback on ASP.NET| File Bugs| Support Lifecycle

United States English English IBM® Site Understand that English isn't everyone's first language so be lenient of bad spelling and grammar. Activex Control '8856f961-340a-11d0-a96b-00c04fd705a2' Cannot Be Instantiated Because Sorry everyone. Web Browser Cannot Be Instantiated Because The Current Thread Is Not In A Single-threaded Apartment Assigning a unique representation to equivalent circular queues Am I interrupting my husband's parenting?

how can solve this issue Rate this: Please Sign up or sign in to vote. When the program resumed from sleep mode and run() was called it was being run on the windows event worker thread instead of the main thread. Join them; it only takes a minute: Sign up Cannot be instantiated because the current thread is not in a single-threaded apartment [closed] up vote 0 down vote favorite So whilst You need to follow the single-threaded apartment contract for a thread to use WebBrowser: must be an STA, use [STAThread] on Main() or Thread.SetApartmentState() if you create a thread. Failed To Set The Specified Com Apartment State.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL) Top Experts Last 24hrsThis month OriginalGriff 435 John Simmons / outlaw Newton's second law for individual forces Can I switch from past tense to present tense in an epilogue? Windows 2008: Locate the Application Pool which houses the ibmcognos website TIP: By default, this is 'DefaultAppPool' You can check this by clicking "Advanced Settings": You should see an entry for navigate here Normally it works fine but if the computer is put into sleep mode and then woken the program will crash with the following error: "System.Threading.ThreadStateException crossed a native/managed boundary Message=ActiveX control

for more details please refer C# Web Browser Console Application After further debugging I found that it only happens after the program is slept and resumed. I'll be working with this knowledge today to hopefully find a fix.

The Form is not an Activex control and you can't use it in a web page, so it's hardly it's fault.

In most cases, it is triggered when the IIS application pool has shutdown, due to inactivity of the end user exceeding its time limit. something like below. This ensures that the SystemEvents class is properly initialized. –Hans Passant May 10 '12 at 3:17 Hi Hans, thank you for the reply. Setapartmentstate Problem solved! ;) –ECC Mar 17 '14 at 20:05 add a comment| up vote 3 down vote If you used [STAThread] to the main entry of your application and still get

Is it professional to disagree with a superior's technical decision in front of others? Depalindromize this string! Would you like to answer one of these unanswered questions instead? his comment is here WEB ASP.NET MVC ASP.NET Core ASP.NET Web Forms JavaScript LightSwitch Silverlight DESKTOP Windows Forms WPF UWP FREE ICONS Metro Studio MOBILE Xamarin UWP JavaScript WinRT Windows Phone Orubase FILE FORMATS Excel

Terms of Service Layout: fixed | fluid CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100 The error message indicates that the control requires the thread be a Single Threaded Apartment.