Windows Service and OCX

I

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.
 
T

Tom Shelton

igor said:
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).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top