The problem is that an activeX control has to run in an STA and therefore
all calls to it will be marshalled on to a single thread (unless you play
nasty with it and pass direct interface pointers to other threads).

ActiveX controls are not usually written with multithreading in mind - how
do you know its threadsafe? If it truely is thread safe and ok to call from
an MTA thread you could try setting your threading model to Both and see if
VS will be happy with that (I've not tested that).

Regards

Richard Blewett - DevelopMentor

> -----Original Message-----
> From: Discussion of advanced .NET topics. [mailto:ADVANCED-
> [EMAIL PROTECTED] On Behalf Of Pavlo Batsii
> Sent: 11 September 2007 13:56
> To: [email protected]
> Subject: Re: [ADVANCED-DOTNET] MTA ActiveX - .NET interop
>
> Richard,
> I have inherited the component and it has some legacy UI which must be
> kept
> (for other native clients).
> The context in which I would like to run ActiveX code doesn't involve
> its
> UI.
> I would rather avoid splitting the component, also I would avoid
> converting
> it to clean COM component, if that's possible.
>
>
> Thanks &
> with best regards,
> Pavlo Batsii
>
>
> ----- Original Message -----
> From: "Richard Blewett" <[EMAIL PROTECTED]>
> To: <[email protected]>
> Sent: Tuesday, September 11, 2007 3:33 PM
> Subject: Re: [ADVANCED-DOTNET] MTA ActiveX - .NET interop
>
>
> >I have a couple of questions.
> >
> > Is the control a UI element or is it just a component you want to use
> for
> > automation purposes that doesn;t have a UI (say like a timer)?
> > Have you authored the control or is it a component developed
> elsewhere?
> >
> > Regards
> >
> > Richard Blewett - DevelopMentor
> >
> >> -----Original Message-----
> >> From: Discussion of advanced .NET topics. [mailto:ADVANCED-
> >> [EMAIL PROTECTED] On Behalf Of Pavlo Batsii
> >> Sent: 11 September 2007 10:53
> >> To: [email protected]
> >> Subject: [ADVANCED-DOTNET] MTA ActiveX - .NET interop
> >>
> >> How do can man use ActiveX controls from .NET WinForms app
> >> so that reference to the IDispatch-implementing object retrieved
> from
> >> ActiveX control wrapper wouldn't be necessarily marshalled to the
> main
> >> thread and ActiveX code not invoked from STA thread's context? A
> kind
> >> of , I would presume, a trivial question that is, only that I
> couldn't
> >> get an answer anywhere.
> >>
> >> I'll explain:
> >>
> >> if one adds the ActiveX on a form, retrieves a pointer to some
> >> automation object, and tries to call that pointer from other
> thread's
> >> context (not from main form, for example), .NET interop marshalls
> the
> >> pointer to the main form (by putting a windows message to the form's
> >> message queue and processing call at the main form, (in a
> >> BackgroundWorker fashion?)), so that all calls to ActiveX methods
> are
> >> made from the same thread.
> >>
> >> I would like to avoid this, because ActiveX component is thread-safe
> >> and, actually, such behaviour is not acceptable since ActiveX method
> >> may block, and it is invoked from a server application (that is,
> >> ActiveX method implementation must be called asynchronously, not one
> by
> >> one).
> >>
> >> If ActiveX is registered as MTA @ registry then VS designer throws
> an
> >> exception when dragging ActiveX on a form.
> >>
> >> Any solutions in case this marshalling cannot be 'disabled'?
> >>
> >> Thanks!
> >>
> >>
> >>
> >>
> >>
> >> If I add ActiveX control on a form (WinForm application),
> >> get a reference to some
> >>
> >> ===================================
> >> This list is hosted by DevelopMentorR  http://www.develop.com
> >>
> >> View archives and manage your subscription(s) at
> >> http://discuss.develop.com
> >
> > ===================================
> > This list is hosted by DevelopMentorR  http://www.develop.com
> >
> > View archives and manage your subscription(s) at
> > http://discuss.develop.com
>
> ===================================
> This list is hosted by DevelopMentorR  http://www.develop.com
>
> View archives and manage your subscription(s) at
> http://discuss.develop.com

===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to