Re: Service hangs when accessing ActiveX control



On Tue, 13 Sep 2005 20:31:59 +0200, "Willy Denoyette [MVP]"
<willy.denoyette@xxxxxxxxxx> wrote:

> So what you should do is create the from and the control's instance from an
> (the same) STA thread, but again, this is not something I strongly advise
> against.

Thanks. I suppose there's a "not" too many there?


But it doesn't even work: the form is created in the constructor of the
service class, which is instantiated from a sub Main with <STAThread>
attribute.
The form is used only as a container for the control.

Just to see if there's a difference I changed it into <MTAThread>.
That causes a ThreadStateException when the service is started, so it's not
like the <STAThread> was ignored (which it would be if there was no COM
interop).


So I guess I'll have to port the control's code to a managed dll.
I've already had to do that with another piece of code in another
application, but this time it doesn't look as if it will be simple, and
time is pressing :(
.



Relevant Pages

  • Re: Service hangs when accessing ActiveX control
    ... STA thread, but again, this is not something I strongly advise against. ... service class, which is instantiated from a sub Main with attribute. ... That causes a ThreadStateException when the service is started, so it's not like the <STAThread> was ignored. ...
    (microsoft.public.dotnet.framework.interop)
  • Re: Service hangs when accessing ActiveX control
    ... >> STA thread, but again, this is not something I strongly advise ... The STAThread attribute is ignored on Main in a service, ... > So I guess I'll have to port the control's code to a managed dll. ... Controls in .NET are UI elements and have the same ...
    (microsoft.public.dotnet.framework.interop)
  • Re: Folders in FolderBrowserDialog disappears!
    ... This is usually caused by not showing the dialog on an STA thread. ... Make sure you ahve the [STAThread] attribute on your Main method if ... Mattias Sjögren mattias @ mvps.org ...
    (microsoft.public.dotnet.languages.csharp)