Re: Service hangs when accessing ActiveX control
- From: "Willy Denoyette [MVP]" <willy.denoyette@xxxxxxxxxx>
- Date: Tue, 13 Sep 2005 20:31:59 +0200
"Lucvdv" <replace_name@xxxxxxxx> wrote in message
news:j3rdi1pp8gvtk7atb1pm2kpai72tu1vijf@xxxxxxxxxx
> On Tue, 13 Sep 2005 16:57:01 +0200, Lucvdv <replace_name@xxxxxxxx> wrote:
>
>> Is there something that has to be taken special care of when using an
>> ActiveX control in a .Net service application?
>
> Add: I've used the same ActiveX control before in services written in VS6,
> and there it works, so it has to be .Net-related.
>
> Something with the activex interop dll's that makes them unsuited for
> services?
First off, ActiveX and Windows Forms should never be used from within
Windows Services, they aren't designed for this kind of scenarios.
The reason your call blocks is that both your form and your control must
live in an STA, now for the AX control this is taken care of by COM itself
which will spin-up an STA thread when you create an instance on an MTA
thread, but your Windows Form will run on an MTA thread (unless you created
the form from an STA thread) and as such can't do the required message
pumping in the COM thread (STA). The result is blocking COM calls.
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.
Willy.
.
- Follow-Ups:
- Re: Service hangs when accessing ActiveX control
- From: Lucvdv
- 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
- Service hangs when accessing ActiveX control
- Prev by Date: Re: simultaneous calling COM object method
- Next by Date: Re: Does the CCW for VB6 to .NET interop give me early or late binding?
- Previous by thread: Re: Service hangs when accessing ActiveX control
- Next by thread: Re: Service hangs when accessing ActiveX control
- Index(es):
Relevant Pages
|