简体   繁体   English

如果从Microsoft的代码中抛出异常,我如何找出最初导致异常的内容?

[英]How do I find out what originally caused an exception, if it gets thrown from Microsoft's code?

I have two controls containing DataGridView s on different panes in a DockPanel . 我在DockPanel不同窗格上有两个包含DataGridView的控件。 If one is in edit mode and I switch pane, I get a NullReferenceException thrown from within the DataGridView 's EndEdit() method. 如果一个处于编辑模式并且我切换窗格,我会从DataGridViewEndEdit()方法中抛出NullReferenceException 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. 我在反射器中看过那个方法,我看不到任何明显的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. 我怀疑这个问题实际上是在我的代码中,但异常是从Microsoft的代码中重新抛出,并且正在重置堆栈跟踪。 How do I find out what originally caused the exception? 我怎样才能找出最初造成异常的原因?

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? 如果您怀疑MS代码中存在错误,可以从符号服务器下载调试符号,加载它们并在调试时跟踪它? 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属性?

Follow the instructions to set up MS symbol server and source server 1 . 按照说明设置MS 符号服务器源服务器 1 Set the debugger to break on NullReferenceException being thrown. 将调试器设置为在抛出NullReferenceException时中断。 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. 1注意,列出的QFE包含在SP1中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM