How to make stacktrace include linenumber for release compiles?

G

Guest

Hi. I've noticed that, when I build an exe in release mode (as opposed to
debug mode), the StackTrace for exception does not include line numbers. Is
there a way that I can build in release mode and still get the line number in
my stack traces?
 
G

Guest

Hi. I've noticed that, when I build an exe in release mode (as
opposed to debug mode), the StackTrace for exception does not include
line numbers. Is there a way that I can build in release mode and
still get the line number in my stack traces?

I believe you have to include the debug PDBs.
 
G

Guest

I have figured out how to do it. In project properties "optimizations"
uncheck "enable optimizations". In project properties "build", check
"Generate Debugging Information".

Problem is, to get the line numbers to come out, it seems you've got to
deploy the "pdb" file which gets generated in the build. This seems a bit
insecure. Is there a way you can get the line numbers without deploying the
"pdb" file?
 
G

Guest

Problem is, to get the line numbers to come out, it seems you've got to
deploy the "pdb" file which gets generated in the build. This seems a bit
insecure.

That is my understanding - if you want line numbers, you deploy the .pdb
file, and you in essence you publish your source code. In closed
environments, that is probably ok, but it is not good for commercial products.
Is there a way you can get the line numbers without deploying the "pdb" file?

Here is an experiment you can try if you are up to it. The /Zd and/or /Z7
compiler options talk about line numbers without a .pdb file. During the
compile phase, some extra information is included in the .obj file. Maybe
this information is included in the .exe file, perhaps with an additional
linker option. Maybe the debugger and/or stacktrace will respect the line
number info when it is located in the .exe file vice the .pdb file.

I give this suggestion has a modest probability of success. Debug info in
the .obj file is an older concept than a .pdb file, and I guess that the
older way is no longer supported (a conjecture, not a fact). However, some
digging about compiler and linker options and a few experiments should tell
the tale. My specific guess is that you will be able to get line numbers
into the .exe file but that .net will not use them. If you have any success,
please post back.

Others have raised this problem. My suggestion to MS is to provide /brief
..pdb files for release configuration and /full .pdb files for debug
configuration.
 
G

Guest

Thanks for your comments. I agree with you recommendation for MSFT.

I don't see any place to specify such compiler options for a VB.NET project
(at least working from within VS.NET). Am I missing it?

Dan
 
G

Guest

I don't see any place to specify such compiler options for a VB.NET project
(at least working from within VS.NET). Am I missing it?

Probably not. I'm on shaky ground here, but you probably have to leave the
confines of VS.NET. This raises the question of whether the experiment is
worth the trouble given its low (my estimate) probablity of success.

As I said before, you are not the first to raise this issue. I wish someone
from MS would give some guidance. Is anybody listening? Maybe an MVP can
make a most valuable contribution - after all, that is why they pay the MVPs
the big bucks (just kidding). Who knows - maybe MS is about to release a
..net upgrade that includes a .pdb with options.

Sorry, I don't have any answers, only an open ended experiment of dubious
value.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top