PDB and ClickOnce

Bit of history first. PDB – Program Debug Database is essential sometimes during debugging. By default, stack trace points to the function where problem lies and don’t include line numbers at which errors are thrown. Sometime this becomes quite critical for a serious production issue. Best practice seems to build PDBs during your build process (both Debug / Release), exclude them while creating your installers, and ship them to production when you need to diagnose your code. Another related thing you might want to keep in mind while debugging some critical issue – you can create a debug build by turning off code optimization (project properties -> Build Tab -> Optimize Code (uncheck)). This helps you to get an accurate stack trace devoid of any code optimizations like inline functions. Let’s get back to PDBs, the topic of this post. Enabling PDB effect normally is done by turning them on (Project Properties -> Build -> Advanced -> Debug Info = pdb-only) and copying generated PDBs to deployment directory. But when you are using ClickOnce things are different. In ClickOnce, the assemblies are downloaded the client’s local machine and then executed (deriving the benefit of auto update). So how do you ensure that the client download PDBs with assemblies? Fortunately VS.NET simplifies this for us. Steps are below:

1) Go the publish tab of your project file and click on “Application Files” button.

2) By default PDB files are not bundled for publish. You need to check “Show All Files” check box and then you would get to see PDB. PDB again is excluded by default, so include them. And you are all set to get line numbers and file names with your stack trace.

Hope this helps 🙂 .

2 thoughts on “PDB and ClickOnce

  1. I have been trying (in vain) to download the PDB files on demand via the Download Group option. In the Application Files dialog I created a download group named “PDB” and for each pdb file, I set Publish Status=Include and DownloadGroup=PDB

    Strange thing I am seeing is that the pdb files are getting downloaded with the rest of the application as if they were not part of a group.

    If I look in the manifest, I see the optional=”true” for each of the pdb files.

    So it seems like I am doing everything correctly and the pdb files should not be getting initially downloaded.

    Any thoughts?

  2. I just spent about 8 hours attempting to get debugging to work on a one-click install. Thanks for taking the time to put together this page.

    I could get the debug to work when I was logged on with the same user account on my development and test PC but the symbols were not being found when I was logged on as a different user on the test box.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s