views:

201

answers:

3

Hi!

I want my application to be distributable as a single .exe file but I want to be able to get nice error reports with source code line numbers (the application simply sends email with exception.ToString() and some additional information when unhandled exception occurs).

Is there any way to embed .pdb into assembly?

A: 

I might be wrong, but doesn't the compiling the project in the debug mode include line numbers, without the need of the PDBs?

Yurik
Try removing PDB and look at stack trace. You won't see line numbers even in debug. Try the opposite - compile for release, check you have PDB near your binaries and enjoy line numbers in stack trace.
Konstantin Spirin
+5  A: 

Use MiniDumps instead of "exception.ToString()". It will give you a lot more information and does not need the .pdb to be distributed with the .exe.

Useful Link: Post-Mortem Debugging Your Application with Minidumps and Visual Studio .NET

Dietmar Hauser
Absolutely, however you need to keep the PDBs of every build you ship for that to work reliably - best to setup a symbol server internally (see http://msdn.microsoft.com/en-us/library/ms680693(VS.85).aspx)
Christian.K
Can I make minidump of a running application? For example, if I get unhandled exception in WinForms, I will display error dialog to the user with an option to send error report and **continue** working with application (in contrast to terminating application).
Konstantin Spirin
Yes, read the linked article.
Dietmar Hauser
+2  A: 

You could write a stub executable, that contains as embedded resources, both your actual executable and its pdb file. Upon starting the staub executable, it extracts the real executable and the pdb into a temporary directory and launches it.

Just like some Installers or other applications do.

I'm not sure if it is worth the extra effort though.

Christian.K
I also had this idea. This will also let me to apply compression to my binaries and make .exe smaller. The drawback is longer start up time. I just hope there's a simpler way of doing this.
Konstantin Spirin