tags:

views:

59

answers:

4

I've attached to a running .net 1.1 application using Visual Studio 2008. I have the debug symbols and the code on the local machine. If an exception occurs, the code pops up fine. However I can't work out how to view the code and set a breakpoint pre-emptively.

Is there a trick?

A: 

Hit Debug > Break All. Once the application pauses, open up the relevant source file and it should allow you to set a breakpoint before hitting continue.

280Z28
+1  A: 

First of all, it may have been a .NET 1.1 application, but you're not running .NET 1.1 in VS2008 - you're running .NET 2.0.

Second, the trick is so obvious that it's obvious why you didn't know - open the source file, and set the breakpoint.

John Saunders
He's attaching to a running process, which means he's not necessarily building it in VS2008, which means it may very well target 1.1. :)
280Z28
I don't think so. I don't see the VS2008 debugger running under the .NET 1.1 CLR. I bet it's running the .NET 2.0 CLR.
John Saunders
Hi guys, I'm attaching to nunit.exe which in turn is loading up my 1.1 unit tests, so it's a 2.0 environment.
James L
Thank you John!
James L
Visual Studio 2005 / 2008 are perfectly capable of debugging .Net 1.1 processes.
Kragen
And, when those processes run, which CLR are they running? When the debugger is debugging them, which CLR is the debugger running? I can conceive of it, I've simply never seen any reliable evidence of the two CLRs coexisting.
John Saunders
I'd love to see the output of System.Environment.Version.ToString() when the "1.1" code is running.
John Saunders
A: 

cordbg.exe can debug .Net 1.1 processes and you have it in the 1.1 SDK, but is rather painful to use. Also Windbg with the original SOS. Here is a good SOS cheat sheet for Windbg.

Remus Rusanu
A: 

My debugging checklist:

  • Make sure your attaching to the process using the correct code type - if your process has both unmanaged and managed code then dont rely on "auto" to work for you, explicitly state what sort of code your trying to debug
  • Goto the modules window (Debug -> Windows -> Modules, you may need to enable it in the "Customize..." menu
  • Check to make sure that the assembly your trying to debug has been loaded, and that symbols have been loaded - if they haven't been loaded then right click on that module and select "load symbols"
  • Open your code file and place your breakpoint - if it appears with the little warning symbol then look and see what it says,
  • You might need to goto "tools -> options - > debugging -> general" and untick "Enable Just My Code (Managed Only)"
  • You might also want to uncheck "Require source files to exactly match the original version", if you think your sources might be slightly out (beware however, as this can lead to you debugging with completely the wrong sources, which can be very confusing)

On certain cases you might find that your module doesn't get loaded at the point where you attach your debugger (for example if you have some sort of plug in archetecutre, and plugin assemblies are only loaded when you first use them). In these cases all you can do is try and make sure everything is prepared ready for when the module is loaded.

Kragen