开发者

Exceptions limited information in compiled C# applications

开发者 https://www.devze.com 2023-01-19 18:14 出处:网络
When I debug an application in C# and an exception happens, the Exception object contains a lot of information. For instance: the class and method that caused the exception. I log this information to

When I debug an application in C# and an exception happens, the Exception object contains a lot of information. For instance: the class and method that caused the exception. I log this information to a log file.

When I built/compile an application, I get very little infor开发者_JS百科mation in my log file. Something like "Property does not exist", without any information about which class, method or property caused the exception.

How can I change that?


Are you logging with ex.ToString() or just ex.Message? You want the former.


In addition to Steven's answer, note that stack trace information will be "truncated" if you're creating a Release build, as opposed to a Debug build. That is, Debug builds include line numbers and so forth, but Release builds won't.

0

精彩评论

暂无评论...
验证码 换一张
取 消