Colin Bowern

... more of the usual bool

  Home  |   Contact  |   Syndication    |   Login
  21 Posts | 0 Stories | 32 Comments | 24 Trackbacks

News

Archives

Post Categories

Monday, February 06, 2006 #

Have you ever had the need to get line numbers from an exception stack trace for an assembly in the GAC?  If you work with BizTalk Server the answer is likely yes.  To debug Commerce Server pipeline components which I have traditionally put custom C# pipeline components in the GAC and then registered for COM interop.  I've found having line numbers indespensible when apps are running in the production test environment. I went searching for the answer and came across it.  I thought I'd write it down here so I remember it.

To get line numbers with your stack trace:

  1. When compiling both debug and release builds make sure to generate a program database (aka symbols). 
    • For release builds you'll want to make sure you use the correct switch, /debug:pdbonly, since /debug:full disables optimization.
  2. When you need line numbers place the .pdb file beside your assembly (in the same folder). 
    • For GAC assemblies you'll need to put it in the assembly folder (e.g. c:\windows\assembly\gac\\__)
    • Be aware that the .NET Framework 2.0 is adding platform specific GAC folders (e.g. GAC, GAC_32, GAC_MSIL, etc...).

Then you should have line numbers in your stack traces.  It's great for debugging and the program databases can be in place for explicit debugging needs and then removed if you don't feel comfortable with them there.