I have this code (using CLRMD) currently to attempt to get the stacktrace:
var pid = Process.GetCurrentProcess().Id;
using (var dataTarget = DataTarget.AttachToProcess(pid, 5000, AttachFlag.Passive))
{
ClrInfo currentRuntime = dataTarget.ClrVersions[0];
var runtime = currentRuntime.CreateRuntime();
Debug.Print("Stack Traces:");
foreach (var t in runtime.Threads)
{
if (t.ManagedThreadId == 1)
{
foreach(var f in t.EnumerateStackTrace())
{
Debug.Print(f.Method?.GetFullSignature());
}
}
}
Debug.Print("");
}
And it prints out this:
System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame)
System.Windows.Threading.Dispatcher.PushFrame(System.Windows.Threading.DispatcherFrame)
System.Windows.Application.RunDispatcher(System.Object)
System.Windows.Application.RunInternal(System.Windows.Window)
System.Windows.Application.Run(System.Windows.Window)
System.Windows.Application.Run()
App.App.Main(System.String[])
But when I open up the threads
tab under debugging in Visual Studio, I see a much more descriptive Location
tab that has this:
App.exe!App.ViewModels.SomethingSomethingViewModel.SomethingHandler
App.exe!App.ViewModels.SomethingSomethingParentViewModel.SomethingCommandHandler() Line 110
App.exe!App.Utilities.AsyncRelayCommand.ExecuteAsync(object parameter) Line 55...
How do I get the stacktrace with location tab information? Visual studio shows it perfectly, but I can't seem to find out how to access that through code so I can send it up as a log...