WebBroser Control from STA

Tech-Archive recommends: Fix windows errors by optimizing your registry



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

.



Relevant Pages

  • Re: how not to expose source code
    ... it's rather easy to take a dll and pop it into full source code ... the salamagar tool even goes as far as ... Compiled dlls have MSIL code but not the real source code. ... The code would compile to a ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: how not to expose source code
    ... I looked at my dll with a hex viewer. ... Compiled dlls have MSIL code but not the real source code. ... The code would compile to a ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: how not to expose source code
    ... Compiled dlls have MSIL code but not the real source code. ... dll and could not be viewed when used in a vs.net project. ... The code would compile to a ... separate dll and could not be viewed when used in a vs.net project. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: how not to expose source code
    ... Blog: http://www.msmvps.com/blogs/alvin ... Compiled dlls have MSIL code but not the real source code. ... dll and could not be viewed when used in a vs.net project. ... The code would compile to a ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: where to find bin, include and lib directories in tcl8.0 version source code
    ... >1) so i went to tcl website and downloaded the tcl 8.0.5 version and ... >somewhere and gave the path and so i generated the dll file. ... >directory at all in the tcl8.0 version source code. ... i have used this link to download ...
    (comp.lang.tcl)