简体   繁体   中英

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 . 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?

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属性?

Follow the instructions to set up MS symbol server and source server 1 . 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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