Code:
using System.Diagnostics;
using System.Linq;
using Microsoft.Diagnostics.Runtime;
using Microsoft.Diagnostics.Runtime.Utilities;
using Microsoft.Diagnostics.Runtime.Utilities.Pdb;
namespace myDiagnostics
{
public class myStackTraceInfo
{
public void Atach()
{
using (DataTarget target = DataTarget.AttachToProcess(Process.GetCurrentProcess().Id, 5000, AttachFlag.Passive))
{
ClrRuntime runtime = target.ClrVersions.First().CreateRuntime();
foreach (ClrThread thread in runtime.Threads)
{
foreach (ClrStackFrame frame in thread.StackTrace)
Console.Write(frame.Method.ToString());
}
}
}
}
}
As a result, I get instead of method names - "UNKNOWN". But the in method is the field "InstructionPointer", maybe it will give more information?