In my error handler code if I put in a breakpoint and hover over the exception I can see the line numbers in the stacktrace. If I store my exception's stacktrace into a string variable to log it, the line numbers are not showing.
This isn't a PDB issue as I'm running debug mode, and the line numbers are there for the exception if I look at it using intellesense... but not if I try to store the value.
If I use the immediate window I get the following with line numbers:
ex.InnerException
{"Object reference not set to an instance of an object."}
Data: {System.Collections.ListDictionaryInternal}
HResult: -2147467261
HelpLink: null
InnerException: null
Message: "Object reference not set to an instance of an object."
Source: "TestProject"
StackTrace: " at TestProject.Client.GraphAPI.<GetOrphans>d__0.MoveNext() in C:\\source\\TestProject\\TestProject\\Client\\GraphAPI.cs:line 23\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n at TestProject.ViewModels.TemplatesViewModel.<FindOrphans>d__31.MoveNext() in C:\\source\\TestProject\\TestProject\\ViewModels\\TemplatesViewModel.cs:line 133"
TargetSite: {Void MoveNext()}
but if I try to access the StackTrace part of that to save the string I get this:
ex.InnerException.StackTrace
" at TestProject.Client.GraphAPI.GetOrphans(AuthenticationResult auth, String FolderID, List`1 ExistingIds)\r\n at TestProject.ViewModels.TemplatesViewModel.FindOrphans()"
Why is the value of StackTrace different when I try to access it than if I'm looking at the entire object?
If it matters these exceptions are generated by a Caliburn.Micro project capturing Coroutine.Completed events for uncaught errors.