Home All Groups Group Topic Archive Search About

Windows Service and OCX

Author
26 Dec 2006 9:52 PM
igor
I recently attempted to incorporate an OCX into a .net windows service
using .net framework 1.1
The ocx failed to perform as expected, meaning the OCX events failed to
execute.  I specifed the withevents clause in my declaration.

When the same ocx is copied onto a windows form, everthing works great.

Is there some way I can use the OCX inside of a windows service?  It
would save me development time.

Any ideas would be helpful.

Thank you.

Author
26 Dec 2006 10:09 PM
Tom Shelton
igor wrote:
> I recently attempted to incorporate an OCX into a .net windows service
> using .net framework 1.1
> The ocx failed to perform as expected, meaning the OCX events failed to
> execute.  I specifed the withevents clause in my declaration.
>
> When the same ocx is copied onto a windows form, everthing works great.
>
> Is there some way I can use the OCX inside of a windows service?  It
> would save me development time.
>
> Any ideas would be helpful.
>
> Thank you.

ActiveX controls require a message pump to fire there events.  There is
no message pump in a windows service.  One way around this is to call
Application.Run() on the thread is created on to start a message pump.
You will probably also have to make sure that your threads are STA
threads as well or you may have interesting results accessing the ocx.

You may experience problems using Application.Run in a service...  I
haven't tried it myself - but I use this method to use COM components
in console apps on occassion (which have the same issue with regards to
com events).

--
Tom Shelton

Bookmark and Share

Post Thread options