Wednesday, January 28, 2009

Remote Debugging and Loading a Symbol File

While doing some exploratory SharePoint development, I ran across a peculiar situation. My development methods generally don't require a lot of remote debugging, but since I was exploring possibilities, I dove farther into it. I deployed my solution to my server, started remote debugging on the server, and attached to the w3wp worker processes.

I opened the Modules window (Ctrl+Alt+U) in Visual Studio and located my assembly. (Note: The image on the left does not contain my assembly, but is just for reference) The Symbol Status column had the phrase "Cannot find or open the PDB file." and didn't say "Symbols loaded." as I had expected. So, I tried to load the symboles by:
Right click on module -> "Load Symbols From" -> "Symbol Path"

This opened up an open file dialog. Selecting the PDB file on my hard drive produced an error about not being able to find the file. It was not immediately obvious why it couldn't find the file. After some experimentation, I discovered that the paths in the "Symbol File" column are specific to the computer being debugged and not translated by the remote debugging functionality. I had assummed that the symbol files loaded were from my local computer and not from the remote server. After I discovered this, I was able to correctly place the PDB file on the remote server, re-attach to the processes, and magicly the symbol loaded.

There isn't much information on the web on this topic, so hopefully this will save someone a headache.

Tuesday, January 27, 2009

Where Did Debug Go?

A little while ago I loaded a project into a new install of Visual Studio 2008. I didn't think about it much at the time, but the "Solution Configuration" dropdown list (the one w/ Debug/Release compile options) was disabled on the screen. I tried to do some debugging and set my breakpoints. When the debugger attached to the process it couldn't set the breakpoints; the code wasn't compiling in debug mode.

I looked at the Modules panel in VS2008 and found that the assembly had compiled with optimization "on". Apparently the last time I compiled I my project, it was in Release mode. I look at the project properties and found the settings to be that of the Release, confirming my previous thought. I looked at the top of the build properties page and there was no dropdowns to switch to a different build configuration.

I thought perhaps something in the project file was not setup correct. So I opened the project file in notepad and looked for the build options. Everything looked like it was in the correct place and further confirmed the Release mode settings.

My next place to check was in Tools -> Options. I looked in all of the options in the tree, nothing jumped out at me. I talked with my colleagues and no one knew how to fix my issue.

I turned to my friend Google and several searches after finding nothing that seemed to fix my issue I had a glimmer of hope. The forum question:

Visual Studio 2008's Build Configuration ONLY offers DEBUG build option -- where did RELEASE GO?

That was amazingly similar to what I was experiencing but I was stuck in Release mode. Awesome, I could feel the solution to my issue was at hand. I looked to find the post marked as the answer only to find disappointment. I continued reading the posts after that and found a post by InteXX which stated:

It's in Tools\Options\Projects and Solutions. Select the Show advanced build configurations checkbox and click OK.


Sweet success! I have added a screen shot to help.



I hope this post saves people time hunting around to fix this issue. There isn't much on the web pertaining to it and the option isn't very well located.