October 15, 2003

Remote Debugging over DCOM

Well, I have been hung up for over a week with a weird bug in one of my C# apps. What made it even more difficult to track down was that I had to run it in a VMWare session because it is unstable and does nasty things to the system due to its interaction with my kernel-mode driver. (Can you say corrupt the system when you hit a single button... a scriptkiddie paradise.... weeeeeeeeeeee)

Well the solution was to use remote debugging. Sounds easy enough. Ya right.

The idea of remote debugging is sound. I use remote debugging over serial... well a named pipe actually pretending to be a com port with VMWare. You can see my HOWTO on that over here. This works great and I have been doing this sort of debugging for over six months now.

So what harm could there be of also remote debugging my application?

Well now that was a pickle. I read every document on MSDN, in the Help docs and through newsgroups. All I had to do was install Remote Debugging Components within the VMWare session and it should work fine. NOT.

Tried asking around on IRC and Usenet. I am told to use TCP/IP debugging. After spending a few hours looking on how to do this and trying to set it up I find out it only works for native C/C++ code, and will not work with stand alone C# apps. Grrrrrrrr. Waste more time putting everything back the way it was.

Finally I figure I am going to bite the bullet and just install Visual Studio in VMWare and debug it locally. Of course that fails twice (stupid autorun on my host machine STILL runs after I set AutoRun to 0 in the registry). In desperation I step back and decide to rethink my strategy. I have wasted a week trying to get this working, and nothing is helping.

After spending most of last night googling every combination I could think of for "remote debugging C# application" I found the jewel that saved my life. I found a document over at gotdotnet.com that was written by Min Kwan Park, a guy within the Microsoft CSharp Debugger QA team. The topic of the document? "The VS7 Debugger doesn’t work. What can I do?". No way. This can't be. Sure enough the answer sits in the last few paragraphs of the document.

On XP Pro, because of the default security setting for "sharing and security model for local accounts", this remote debugging is not allowed by default.

GRRRRRRRRRRRRRRRRRRRRRRRR. Its an undocumented setting that has to be changed for remote debugging to work! Well, to be fair I guess it was documented in this jewel, but it wasn't found during the last week of searching on MSDN, the VS help docs or even the newsgroups.

So now everything is working great. With my multiple monitors I have one hosting my remote debug session of my kernel driver with WinDgb and the other hosting my remote debug session of my C# app in the Visual Studio .NET debugger. 2 minutes later I found my bug. (And god what a dumb bug it was).

*sigh*

Posted by SilverStr at October 15, 2003 10:16 AM | TrackBack