Stacktrace information preserving paths of origina

2019-01-15 07:44发布

问题:

I am using C#.net for application development.

To log and debug exceptions, I use the stacktrace.

I executed my application on another machine, but when errors occur it refers to the path of my development machine.

Ex:   D:\Projects\xyz.CS line no :12 _Error_message_here.

Why does it trace to the path on my development machine path even though I am running the application on another machine?

回答1:

The original compiled path is stored in the debug information within the PDB files.



回答2:

Because it's telling you where to find the problem in your source code. So when you see this, you can go to your machine and open the file reported (e.g. "D:\Projects\xyz.cs"), go to the reported line (e.g. 12) and fix the problem.



回答3:

Explanation

When you do a Debug build, it includes source information in the compiled files to enable debugging, e.g. pause, step over, etc.

Solution

If you don't want the source information to be included perform a Release build and deploy that to the other machine.