如果异常是从 Microsoft 代码中抛出的,我如何找出最初导致异常的原因?
我有两个控件,其中包含 DockPanel
中不同窗格上的 DataGridView
。 如果处于编辑模式并且我切换窗格,则会从 DataGridView
的 EndEdit()
方法中抛出一个 NullReferenceException
。 堆栈跟踪不会比这更深入,并且异常不包含任何更多信息。
我在反射器中查看了该方法,但看不到任何明显为空的内容。 我怀疑问题实际上出在我的代码中,但异常是从 Microsoft 的代码中重新抛出的,这会重置堆栈跟踪。 我如何找出最初导致异常的原因?
I have two controls containing DataGridView
s on different panes in a DockPanel
. If one is in edit mode and I switch pane, I get a NullReferenceException
thrown from within the DataGridView
's EndEdit()
method. The stack trace doesn't go any deeper than that and the exception doesn't contain any more information.
I've looked at that method in the reflector, and I can't see anything obviously null. I suspect that the problem is actually in my code, but the exception is being rethrown from within Microsoft's code and that's resetting the stack trace. How do I find out what originally caused the exception?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您怀疑 MS 代码中存在错误,您可以从符号服务器下载调试符号,加载它们并在调试时跟踪它?
请注意,这些符号受各种许可证之一的约束。 如果(例如)您从事“单一”贡献等工作,这可能会影响您。
If you suspect a bug in the MS code, you could download the debugging symbols from the symbol server, load them and trace it through at debug? Like so.
Note that the symbols are subject to one of the various licences. This may impact you if (for example) you work on "mono" contributions etc.
您是否研究过 InnerException 属性?
Have you looked into the InnerException property?
按照说明设置 MS 符号服务器 和 源服务器1。 将调试器设置为在引发 NullReferenceException 时中断。 然后,您将获得用于调试的完整源代码,或者至少获得完整的堆栈跟踪。
1 请注意,列出的 QFE 包含在 SP1 中。
Follow the instructions to set up MS symbol server and source server1. Set the debugger to break on NullReferenceException being thrown. Then either you will get full source code for debugging, or at least a complete stack trace.
1 Note, the QFE listed is included in SP1.