I am debugging an WCF project (with debug constant on) and come to this problem. I want to log the line number from the StackTrace of an ecxeption when caught
try
{
// ...
}
catch (Exception ex)
{
string message = "Error: " + ex.StackTrace;
// ...
}
And all I got in the message
variable only contains the call stack and method names. What's weird is if I expand the ex
variable in the debugger, I can see the full stack trace with line number. Only if I use the property directly will I get the truncated message.
See the screenshot. In the watch window I added 2 variables: ex
while expanded, and ex.StackTrace. You can see even in the watch window, when accessing directly the line number is stripped.
So what is causing this behavior?