Link to home
Start Free TrialLog in
Avatar of DigitechComputer
DigitechComputer

asked on

How do you publish a VS.NET app with the .PDB debug file included?

I have a Visual Studio C# .NET application that has an error logging routine implemented for unhandled exceptions.  This routine logs the line number that the exception occurred on, and it works fine in debug mode in the dev environment because the .PDB file is present.  However, I want to publish a release of my Visual Studio .NET application and still be able to get the line number that unhandled exceptions occurred on without having to deal with any manual downloading of the latest .PDB file or anything that complicated.

I thought this would be a simple setting in the project options, but I have been unable to find anything that works, nor have I been able to find any solutions on Google.  
Avatar of Ravi Vaddadi
Ravi Vaddadi
Flag of United States of America image

Set the build in debug mode and try publishing from Build menu of VS ide. This would include PDB file as well.
Avatar of DigitechComputer
DigitechComputer

ASKER

I have tried publishing in both Debug and Release mode.  In both cases, the PDB file does not get distributed to users who run it and install the updated build.
How are you publishing? Could you elaborate on it?
I am using Visual Studio's built in publishing feature.  The application properties are configured for a location to publish to, files to include, etc.  To publish, I go to Build -> Publish "application name", and hit Finish.  

I have tried various settings in the application properties to try and get the PDB files to be included in the publish, but nothing has worked so far.  For example, under the application properties' Build tab, I click Advanced, and under Debug Info the drop down is set to "full", but line numbers are still not being logged.  

By the way, I am finding the line number by creating a StackTrace object from the exception that is thrown, then calling stackTrace.GetFrame(0).GetFileLineNumber().  As I said, this works fine when running in debug mode from Visual Studio, but in the build it always returns 0.  If I manually copy all of the PDB files that are in the project's .../bin/Debug directory, the published build will log the line number just fine.
ASKER CERTIFIED SOLUTION
Avatar of Ravi Vaddadi
Ravi Vaddadi
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I knew it would end up being something simple.  I looked in there before to see if I could include the .pdb's, but never noticed the "Show all files" checkbox.  Thanks!