var newStackTrace = new StackTrace(true);
或过时的
var newStackTrace = new StackTrace(Thread.CurrentThread, true);
给我一个不同于我在Visual Studio Pro的“调用堆栈”窗口中看到的StackTrace。当前线程的ManagedId与我在“线程”窗口中选择的ManagedId相同。为了值得,我正在运行Debug构建,其中存在pdb文件,并且源与程序集匹配。
Visual Studio从哪里获取其调用堆栈?与Visual Studio相比,是什么导致System.Diagnostics.StackTrace为同一线程返回不同的StackTrace?
我读到堆栈跟踪是不可靠的,但是如果我能得到与VS相同的跟踪,那将对我有用。
VS的Stacktrace:
> A.S.dll!A.X.BORD.ActivateDebugger(object sender = Name={System.Collections.Generic.Dictionary<string, A.X.BOVar>}; Type=, A.X.ActivateDebuggerEventArgs args = {A.X.ActivateDebuggerEventArgs}) Line 1865 C#
A.S.dll!A.X.BOHost.Debug(object o = {System.Docu.File.DFF}, int line = 93) Line 259 C#
System.Docu.File.DFF.dll!<Unknown function> Line 93 Unknown
A.N.dll!A.N.WC.PB.LoadImageAsync(System.IO.Stream outputStream = {System.Web.HttpResponseStream}) Line 137 C#
A.C.dll!A.C.W.GIAB(A.N.JS.JSO args = {A.N.JS.JSO}, A.N.JS.JSO result = {A.N.JS.JSO}) Line 452 C#
[Native to Managed Transition]
[Managed to Native Transition]
A.N.dll!A.N.CM.AIS.Invoke(System.Reflection.MethodInfo method = {System.Reflection.RuntimeMethodInfo}, object target = {A.C.W}, A.N.JS.JSO[] args = {A.N.JS.JSO[2]}) Line 173 C#
A.C.dll!A.C.W.ProcessRequest(System.Web.HttpContext context = {System.Web.HttpContext}, System.Collections.Specialized.NameValueCollection responseHeader = {System.Web.HttpHeaderCollection}) Line 210 C#
A.N.dll!A.N.Http.HTTPH.ExecuteHandler(System.Web.HttpContext context = {System.Web.HttpContext}, string ashx = "<%@ WebHandler Language=\"C#\" Class=\"A.C.W\" %>\r\n", System.Collections.Specialized.NameValueCollection responseHeader = {System.Web.HttpHeaderCollection}) Line 471 C#
A.N.dll!A.N.Http.HTTPH.ProcessDefaultRequest(System.Web.HttpContext context = {System.Web.HttpContext}, System.Collections.Specialized.NameValueCollection responseHeader = {System.Web.HttpHeaderCollection}) Line 165 C#
A.N.dll!A.N.Http.HTTPH.ProcessRequest(System.Web.HttpContext context = {System.Web.HttpContext}, System.Collections.Specialized.NameValueCollection responseHeader = {System.Web.HttpHeaderCollection}) Line 374 C#
App_Code.8jnywgrm.dll!HandlerModule.Application_AuthenticateRequest(object sender = {System.Web.HttpApplication}, System.EventArgs e = {System.EventArgs}) Line 92 C#
System.Web.dll!System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() Unknown
System.Web.dll!System.Web.HttpApplication.ExecuteStepImpl(System.Web.HttpApplication.IExecutionStep step) Unknown
System.Web.dll!System.Web.HttpApplication.ExecuteStep(System.Web.HttpApplication.IExecutionStep step = {System.Web.HttpApplication.SyncEventExecutionStep}, ref bool completedSynchronously = false) Unknown
System.Web.dll!System.Web.HttpApplication.PipelineStepManager.ResumeSteps(System.Exception error) Unknown
System.Web.dll!System.Web.HttpApplication.BeginProcessRequestNotification(System.Web.HttpContext context, System.AsyncCallback cb) Unknown
System.Web.dll!System.Web.HttpRuntime.ProcessRequestNotificationPrivate(System.Web.Hosting.IIS7WorkerRequest wr = {System.Web.Hosting.IIS7WorkerRequest}, System.Web.HttpContext context = {System.Web.HttpContext}) Unknown
System.Web.dll!System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(System.IntPtr rootedObjectsPointer, System.IntPtr nativeRequestContext = 0x0000022413f56d40, System.IntPtr moduleData, int flags) Unknown
System.Web.dll!System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(System.IntPtr rootedObjectsPointer, System.IntPtr nativeRequestContext, System.IntPtr moduleData, int flags) Unknown
[AppDomain Transition]
StackTrace中的Stacktrace:
at A.X.BORD.ActivateDebugger(Object sender, ActivateDebuggerEventArgs args) in X:\trunk\Source\S.X.BORD.cs:line 1865
at A.X.BOHost.Debug(Object o, Int32 line) in X:\trunk\Source\S.X.BOHost.cs:line 259
at System.Docu.File.DFF.LoadImage(Object sender, LoadImageEventArgs args) in SCRIPTFILE:line 24
at A.N.WC.PB.LoadImageAsync(Stream outputStream) in X:\trunk\Source.N.WC\PB.cs:line 137
at A.C.W.GIAB(JSObject args, JSObject result) in X:\trunk\Source.C.W.cs:line 452
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
at A.N.CM.AIS.Invoke(MethodInfo method, Object target, JSObject[] args) in X:\trunk\Source.N.CM\AIS.cs:line 173
at A.C.W.ProcessRequest(HttpContext context, NameValueCollection responseHeader) in X:\trunk\Source.C.W.cs:line 210
at A.N.Http.HTTPH.ExecuteHandler(HttpContext context, String ashx, NameValueCollection responseHeader) in X:\trunk\Source.N.Http\HTTPH.cs:line 471
at A.N.Http.HTTPH.ProcessDefaultRequest(HttpContext context, NameValueCollection responseHeader) in X:\trunk\Source.N.Http\HTTPH.cs:line 165
at A.N.Http.HTTPH.ProcessRequest(HttpContext context, NameValueCollection responseHeader) in X:\trunk\Source.N.Http\HTTPH.cs:line 374
at HandlerModule.Application_AuthenticateRequest(Object sender, EventArgs e) in X:\trunk\www\WAS\App_Code\HandlerModule.cs:line 92
at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step)
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
at System.Web.HttpApplication.PipelineStepManager.ResumeSteps(Exception error)
at System.Web.HttpApplication.BeginProcessRequestNotification(HttpContext context, AsyncCallback cb)
at System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context)
at System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr rootedObjectsPointer, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)
at System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr rootedObjectsPointer, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)
对于在IIS上运行的大型复杂应用程序,它是非常不同的(不同的堆栈框架,行号),对于下面列出的程序,只有行号不同:
namespace stacktrace
{
class Program
{
static void Main(string[] args)
{
var stacktrace = new System.Diagnostics.StackTrace(true);
}
}
}
一旦考虑到“从托管到本机/从本地到托管的过渡”位,并且忽略了格式设置(混淆堆栈在这里为我提供了帮助:-)),除了从第三个帧开始,堆栈基本相同最佳;报告“ System.Docu.File.DFF”的文件。 System.Docu.File.DFF.dll是我们由用户“ pseudocode”通过反射生成的程序集。
我很高兴StackTrace找到了方法名/行,并为VS没有感到困惑...这就是我需要帮助的地方。