3
votes

I have a Windows Service written in .NET C# which calls a COM component. I also have a .NET Windows Forms test app which I was using to test the COM component. It works fine from the test app. However, when I use the same code in the Windows Service nothing happens. The COM components logs everything to file and the fact the log file doesn't get produced hints that the COM component isn't even being called.

Why does this work from my test app but not within the windows service?

2
Please give some detail about the COM component. What is it written in, for instance. Maybe the component assumes it is running in a process that has a message pump.John Saunders
The component is written in ATL with Visual Studio 6. It is an exe component (not dll or service)Jonnster
so, is this the first time you've tried to use the component outside of a desktop application? Never used it in ASP.NET or a web service? That suggests you have a dependency on a message pump or something else that doesn't exist outside of a desktop application.John Saunders
Yes this is the first time I've tried to use outside anything other than a desktop application. I'm thinking there is some sort of permissions problem which I am trying to narrow down. Right now I want to narrow down whether the method gets called at all.Jonnster

2 Answers

4
votes

Service typically run isolated from the desktop, and therefore your call to the COM component is insulated from the UI when called from the service. You may allow a service to "interactWithDesktop" see the section on Using an Interactive Service.

Microsoft (<sarcasm>in their infinite wisdom</sarcasm>) Decided that this capability would be removed from Window vista and recommend separating your application into multiple parts and using other mechanisms to accomplish communication between your UI and your service. Obviously, some (including myself) don't agree, but, it is what it is...

http://msdn.microsoft.com/en-us/library/ms683502.aspx

http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/e50d8819-d628-48e2-aa2c-6ac6de8380d9/

0
votes

Are you running your service in the LocalSystem account (the default for Windows Services)? Your COM component may need to access resources available in an account that can run it normally...

Try editing your service and specifying your account on the Log On tab.