Craig Bovis
Craig Bovis

Reputation: 2811

Handling Type.InvokeMember Inner Exceptions nicely

I have a bit of code which is calling the InvokeMember method on a Type. This is fine and works however if an exception occurs within the member being invoked then the debug jumps to where I am calling InvokeMember as opposed to the inner exception.

Is it possible to get around this so that the code debugs as expected?

Upvotes: 1

Views: 1078

Answers (2)

David M
David M

Reputation: 72850

Yes it is possible. Press Ctrl-Alt-E in Visual Studio to bring up theExceptions dialog box. Check the box to break on Thrown Common Language Runtime Exceptions (not just User-unhandled ones). Now debug your code and you will find it breaks inside your reflection-invoked method.

Upvotes: 3

Jey Geethan
Jey Geethan

Reputation: 2285

It is actually not possible, because the reflection classes invoke the methods in a different way than you would expect. It is very indirect and if you actually run through the debugger, you would see the different lines of code being executed inside the library files and you will not understand anything worth while from them.

Upvotes: -2

Related Questions