开发者

How to debug unmanaged code in .NET Windows Service?

I have been developing a VB.Net windows service for some time now. It uses a COM class developed in C++.

I haven't been able to use it as a true service because I was using an unregistered 3rd party control that shows a nag screen, so the service crashed. Management finally bought it yesterday, so I've just begun to test it in service mode.

Some time ago I used to debug c++ windows services with a call to DebugBreak() at the开发者_如何学JAVA beginning of the application. For .NET I have found this: How to debug a windows service using breakpoints?

So far, so good; but there's a method call on the COM Object that is failing with error code 0x80004003 when running in service mode, but it works correctly as an application.

The problem is that I'm unable to debug the COM code. If I load a cpp from it in my vs session and put a breakpoint, it's ignored because there are no symbols loaded, even after the COM object is created. If I put a DebugBreak in the C++ code, it raises an exception in .Net, but doesn't ask me to debug the code. In the service project, "Enable unmanaged code debugging" is checked.

I have also tried to use the COM class project, but with no success.

Any idea?

Edit - 2011-01-03: To answer Chris O questions, yes, I can run the process as SYSTEM, but, how would that help me? If everything works as SYSTEM then that's because I need some permissions?

And yes, I am able to attach the debugger to the process, with the limitations stated above: In the "attach to process" dialog from Visual Studio 2005, the service doesn't appear in the process list, so I have to use a Debug.Assert call or similar methods. Also, I'm only able to debug the .Net code; I can't debug native code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜