Re: Service hangs when accessing ActiveX control
- From: Lucvdv <replace_name@xxxxxxxx>
- Date: Thu, 15 Sep 2005 13:47:32 +0200
On Wed, 14 Sep 2005 18:11:36 +0200, "Willy Denoyette [MVP]"
<willy.denoyette@xxxxxxxxxx> wrote:
> The STAThread attribute is ignored on Main in a service, Service threads run
> in an MTA by default, if this is not what you want, you have to create your
> own STA thread.
But observation indicates the opposite.
Not specifying any attribute or specifying it as STA results in the same
behavior. Specifing it as MTA is different, in that it causes a
ThreadStateException when the service is started - probably because the COM
interface checks if it is running in STA.
I can only conclude from that, that the attribute is not ignored in a
service and the default is STAThread.
VS.Net *does* explicitly put <MTAThread()> in the declaration (which I
removed because I was using COM), and maybe it does so because it has to be
that way for a service, but that's not the same as ignoring it.
> > 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).
> >
> Sure there is no difference because ... see above.
>
> >
> > 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 :(
>
> Won't help you, Controls in .NET are UI elements and have the (almost) same
> requirements as AX controls.
I wouldn't make it a control, but a simple class that exposes the same
properties, methods and events (it has no UI elements, in that respect it
behaves like the MS Winsock control among others).
.
- Follow-Ups:
- Re: Service hangs when accessing ActiveX control
- From: Willy Denoyette [MVP]
- Re: Service hangs when accessing ActiveX control
- From: Stephen Martin
- Re: Service hangs when accessing ActiveX control
- References:
- Service hangs when accessing ActiveX control
- From: Lucvdv
- Re: Service hangs when accessing ActiveX control
- From: Lucvdv
- Re: Service hangs when accessing ActiveX control
- From: Willy Denoyette [MVP]
- Re: Service hangs when accessing ActiveX control
- From: Lucvdv
- Re: Service hangs when accessing ActiveX control
- From: Willy Denoyette [MVP]
- Service hangs when accessing ActiveX control
- Prev by Date: IDL incorrect? Cannot use interop-assembly
- Next by Date: Re: Service hangs when accessing ActiveX control
- Previous by thread: Re: Service hangs when accessing ActiveX control
- Next by thread: Re: Service hangs when accessing ActiveX control
- Index(es):
Relevant Pages
|