如何读取此堆栈跟踪 [英] How to read this stack trace

查看:75
本文介绍了如何读取此堆栈跟踪的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当关闭数据绑定的mdi子窗体时,我得到一个未处理的异常错误。



它只发生在运行时,而不是设计时间。



我不明白堆栈跟踪(但我从来没有这样做)



任何帮助都将不胜感激! ! !



When closing a data bound mdi child form I get an unhandled exception error.

It only happens at run time, not design time.

I don't understand the stack trace (but I never do)

Any help would be greatly appreciated ! ! !

Unhandled exception at 11/4/2014 1:46:07 PM

e.Exception.Message = Cannot bind to the property or column RevAcctID on the DataSource.
Parameter name: dataMember

e.Exception.StackTrace =    at System.Windows.Forms.BindToObject.CheckBinding()
   at System.Windows.Forms.Binding.SetListManager(BindingManagerBase bindingManagerBase)
   at System.Windows.Forms.ListManagerBindingsCollection.AddCore(Binding dataBinding)
   at System.Windows.Forms.BindingsCollection.Add(Binding binding)
   at System.Windows.Forms.BindingContext.UpdateBinding(BindingContext newBindingContext, Binding binding)
   at System.Windows.Forms.Control.UpdateBindings()
   at System.Windows.Forms.Control.OnBindingContextChanged(EventArgs e)
   at System.Windows.Forms.ListControl.OnBindingContextChanged(EventArgs e)
   at System.Windows.Forms.Control.CreateControl()
   at System.Windows.Forms.Control.RecreateHandleCore()
   at System.Windows.Forms.ComboBox.RecreateHandleCore()
   at System.Windows.Forms.ComboBox.SetAutoComplete(Boolean reset, Boolean recreate)
   at System.Windows.Forms.ComboBox.OnDataSourceChanged(EventArgs e)
   at System.Windows.Forms.ListControl.SetDataConnection(Object newDataSource, BindingMemberInfo newDisplayMember, Boolean force)
   at System.Windows.Forms.ListControl.DataSourceDisposed(Object sender, EventArgs e)
   at System.ComponentModel.Component.Dispose(Boolean disposing)
   at System.Windows.Forms.BindingSource.Dispose(Boolean disposing)
   at System.ComponentModel.Component.Dispose()
   at System.ComponentModel.Container.Dispose(Boolean disposing)
   at System.ComponentModel.Container.Dispose()
   at TOM.frmItemDetail.Dispose(Boolean disposing)
   at System.ComponentModel.Component.Dispose()
   at System.Windows.Forms.Form.WmClose(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

e.Exception.Source = System.Windows.Forms




Iterating through the Stack Frames...
(Filename= Line 0) Getmethod.module=System.Windows.Forms.dll Getmethod=System.Windows.Forms.BindToObject.CheckBinding
(Filename= Line 0) Getmethod.module=System.Windows.Forms.dll Getmethod=System.Windows.Forms.Binding.SetListManager
(Filename= Line 0) Getmethod.module=System.Windows.Forms.dll Getmethod=System.Windows.Forms.ListManagerBindingsCollection.AddCore
(Filename= Line 0) Getmethod.module=System.Windows.Forms.dll Getmethod=System.Windows.Forms.BindingsCollection.Add
(Filename= Line 0) Getmethod.module=System.Windows.Forms.dll Getmethod=System.Windows.Forms.BindingContext.UpdateBinding
(Filename= Line 0) Getmethod.module=System.Windows.Forms.dll Getmethod=System.Windows.Forms.Control.UpdateBindings
(Filename= Line 0) Getmethod.module=System.Windows.Forms.dll Getmethod=System.Windows.Forms.Control.OnBindingContextChanged
(Filename= Line 0) Getmethod.module=System.Windows.Forms.dll Getmethod=System.Windows.Forms.ListControl.OnBindingContextChanged
(Filename= Line 0) Getmethod.module=System.Windows.Forms.dll Getmethod=System.Windows.Forms.Control.CreateControl
(Filename= Line 0) Getmethod.module=System.Windows.Forms.dll Getmethod=System.Windows.Forms.Control.RecreateHandleCore
(Filename= Line 0) Getmethod.module=System.Windows.Forms.dll Getmethod=System.Windows.Forms.ComboBox.RecreateHandleCore
(Filename= Line 0) Getmethod.module=System.Windows.Forms.dll Getmethod=System.Windows.Forms.ComboBox.SetAutoComplete
(Filename= Line 0) Getmethod.module=System.Windows.Forms.dll Getmethod=System.Windows.Forms.ComboBox.OnDataSourceChanged
(Filename= Line 0) Getmethod.module=System.Windows.Forms.dll Getmethod=System.Windows.Forms.ListControl.SetDataConnection
(Filename= Line 0) Getmethod.module=System.Windows.Forms.dll Getmethod=System.Windows.Forms.ListControl.DataSourceDisposed
(Filename= Line 0) Getmethod.module=System.dll Getmethod=System.ComponentModel.Component.Dispose
(Filename= Line 0) Getmethod.module=System.Windows.Forms.dll Getmethod=System.Windows.Forms.BindingSource.Dispose
(Filename= Line 0) Getmethod.module=System.dll Getmethod=System.ComponentModel.Component.Dispose
(Filename= Line 0) Getmethod.module=System.dll Getmethod=System.ComponentModel.Container.Dispose
(Filename= Line 0) Getmethod.module=System.dll Getmethod=System.ComponentModel.Container.Dispose
(Filename= Line 0) Getmethod.module=TOM.exe Getmethod=TOM.frmItemDetail.Dispose
(Filename= Line 0) Getmethod.module=System.dll Getmethod=System.ComponentModel.Component.Dispose
(Filename= Line 0) Getmethod.module=System.Windows.Forms.dll Getmethod=System.Windows.Forms.Form.WmClose
(Filename= Line 0) Getmethod.module=System.Windows.Forms.dll Getmethod=System.Windows.Forms.Control+ControlNativeWindow.WndProc
(Filename= Line 0) Getmethod.module=System.Windows.Forms.dll Getmethod=System.Windows.Forms.NativeWindow.Callback





PS我使用下面的代码收集上面引用的异常详细信息







P.S. I used the below code to gather the above quoted exception details


Dim Msg1 As String = "Unhandled exception at " & Now.ToString & vbCrLf & vbCrLf
Msg1 += "e.Exception.Message = " & e.Exception.Message.ToString & vbCrLf & vbCrLf
Msg1 += "e.Exception.StackTrace = " & e.Exception.StackTrace & vbCrLf & vbCrLf
Msg1 += "e.Exception.Source = " & e.Exception.Source & vbCrLf & vbCrLf & vbCrLf
Dim MsgFull As String = Msg1 & "Do you wish to attempt to continue?" & vbCrLf & vbCrLf

Dim reply As MsgBoxResult = MsgBox(MsgFull, MsgBoxStyle.OkCancel, "Details logged to C:\tEMP\Unhandled.txt and C:\tEMP\Unhandled-Detailed.txt")
If reply = MsgBoxResult.Ok Then e.ExitApplication = False

Dim sw As New IO.StreamWriter("C:\tEMP\Unhandled.txt", True)
sw.Write(Msg1 & vbCrLf & vbCrLf)
sw.Close()

sw = New IO.StreamWriter("C:\tEMP\Unhandled-Detailed.txt", True)
sw.Write(Msg1 & vbCrLf & vbCrLf)
Dim st As StackTrace = New StackTrace(e.Exception, True)
sw.WriteLine("Iterating through the Stack Frames...")
For Each sf As StackFrame In st.GetFrames
    sw.Write("(Filename=" & sf.GetFileName & " Line " & sf.GetFileLineNumber() & ") Getmethod.module=" & sf.GetMethod.Module.ToString & " Getmethod=" & sf.GetMethod.DeclaringType.FullName.ToString & "." & sf.GetMethod.Name.ToString & vbCrLf)
Next
sw.Write(vbCrLf & vbCrLf)
sw.Close()

sw.Dispose()
Process.Start("C:\tEMP\Unhandled-Detailed.txt")

推荐答案

您需要了解调用堆栈以及异常的工作原理。异常通过从一个try点跳到另一个try点而向上传播。这是一种时间机器机制。

我试图在我过去的答案中解释它(我是结构化异常处理的早期实现的作者,当它在它的时候CLU然后是Ada,但即使在C ++中也没有):

例外情况C#构造函数导致调用者分配失败? [ ^ ],

操作系统中存储.net异常的位置 [ ^ ]。



首先,你需要了解什么是调用堆栈及其角色,然后您需要了解异常机制有自己的堆栈,哪些元素指向调用堆栈中每个线程的位置。它允许您跟踪异常如何传播到代码的某个点。



除了理解理论之外,我还可以建议一个可以给你的实际步骤在每种特定情况下清晰的堆栈视野。捕获顶部堆栈帧上某处的所有异常。在异常处理程序上放置一个断点并在调试器下运行它以观察异常。当执行在断点处停止时,打开名为调用堆栈的调试窗口。在此窗口中,您可以单击每个对应于调用堆栈上某个点的行。单击时,将显示源代码窗口,光标设置在代码中的点上。



它将帮助您理解异常堆栈诊断。另请参阅:

http ://msdn.microsoft.com/en-us/library/system.diagnostics.stacktrace%28v=vs.110%29.aspx [ ^ ],

< a href =http://msdn.microsoft.com/en-us/library/system.diagnostics.stackframe%28v=vs.110%29.aspx> http://msdn.microsoft.com/en-us /library/system.diagnostics.stackframe%28v=vs.110%29.aspx [ ^ ]。



-SA
You need to understand the call stack and how exception work. An exception propagate up the stack by jumping from one "try" point to another. This is a kind of "time machine" mechanism.
I tried to explain it in my past answers (I am the author of a very early implementation of Structured Exception Handling, at the time when it was in CLU and then Ada, but no even in C++ yet):
Does Exception in C# Constructor Cause Caller Assignment to Fail?[^],
where was stored .net exceptions in operating system[^].

First of all, you need to understand what is the call stack and its role, and then you need to understand that the exception mechanism has its own stack which elements point to the positions in the call stack, per thread. It allows you to trace how the exception propagated to a certain point of your code.

In addition to understanding the theory, I can advise one practical step which can give you a clear vision of the stack in each particular case. Catch all exceptions somewhere on the top stack frame. Put a break point on the exception handler and run it under the debugger the way to observe the exception. When execution stops at the break point, open the Debug window called "Call stack". In this window, you can click on the lines each corresponding to some point on the call stack. On click, a source code window will be shown, with the cursor set on the point in code.

It will help you to understand the exception stack diagnostics. See also:
http://msdn.microsoft.com/en-us/library/system.diagnostics.stacktrace%28v=vs.110%29.aspx[^],
http://msdn.microsoft.com/en-us/library/system.diagnostics.stackframe%28v=vs.110%29.aspx[^].

—SA


感谢您的回复。



没有数据源更改事件,但我找到了解决方案这篇在线文章......



http://connect.microsoft.com/VisualStudio/feedbackdetail/view/262053/autocompletesource-listitems-in-combobox -causes-exception-when-form-is-closed [ ^ ]



所以我进入表单关闭最后一行我添加了...



Thanks for your reply.

Nothing for the data source changed event, but I found the solution in this on-line article...

http://connect.microsoft.com/VisualStudio/feedbackdetail/view/262053/autocompletesource-listitems-in-combobox-causes-exception-when-form-is-closed[^]

So i went into form closing and for the last line I added...

If e.Cancel = False then cmbRecAcct.AutoCompleteMode = AutoCompleteMode.None





修复它。



And that fixed it.


这篇关于如何读取此堆栈跟踪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆