.NET Service - Not STA message pump?

  • Thread starter Thread starter SPG
  • Start date Start date
S

SPG

Hi,
I have a problem where a COM component used in our C# windows app works fine
using callbacks etc, but as soon as we compile to a windows service, we no
longer get notification events from the COM object.

After some investigation, I found that the win app starts in an STA thread
state, but the service starts as MTA. I no longer get any events from the
COM object.

I was told that the event pump will not work in the .NET windows service.
Can anyone shed some light (or a workaround)?

Steve
 
Hi

I don't know if .net windows services can handle events from COM objects but notifications from COM objects should work just like any other COM method invocation - through the message queue. Have you tried creating an invisible windows form within your service and use that form the same way as in your first windows app

What happens if you specify the service thread to run as STA (with System.Threading.ApartmentState)

Regards, Jakob.
 
Back
Top