WebBroser Control from STA
- From: karthick.ramachandran@xxxxxxxxx
- Date: 15 Dec 2005 03:41:01 -0800
Hi,
I have an application, for which i dont have the source code. I can
attach a managed code dll to that application and by reflection magic
that application calls the specified method in attached dll.
Now here comes the problem. My dll has a windows form object, which has
a webbrowser control in it. Webbrowser control expects Single Threaded
Apartment. But the application is Multi Threaded Apartment.
So when I run the application, an exception is thrown saying that
System.Threading.ThreadStateException was unhandled
Message="ActiveX control '8856f961-340a-11d0-a96b-00c04fd705a2'
cannot be instantiated because the current thread is not in a
single-threaded apartment."
I **cannot** add the attribute [STAThread] to the invoker as I dont
have the source code of it?
I am not able to change the current thread to MTA as, I dont have the
permission to do it from the dll file.
Is there anyway, I will be able to call the STA com from a MTA thread.
In one of the threads I read that it is possible to change the
registry values of that library and change it to the MTA model.
http://groups.google.com/group/microsoft.public.dotnet.framework.interop/browse_thread/thread/e94ae7b8e7d3baee/c4a5b22262a03eaf?q=webbrowser+apartment&rnum=1#c4a5b22262a03eaf
Is this is a safer approach? Or Is there any elegant solution to this
problem?
Thanks!
- Karthick R
.
- Follow-Ups:
- Re: WebBroser Control from STA
- From: Willy Denoyette [MVP]
- Re: WebBroser Control from STA
- Prev by Date: PowerPoint Add-In wont load under .NET 2.0
- Next by Date: msado21 and SQL Server 2005.
- Previous by thread: PowerPoint Add-In wont load under .NET 2.0
- Next by thread: Re: WebBroser Control from STA
- Index(es):
Relevant Pages
|