Stack trace stops when the System.Reflection "invoke" method is called and exception is thrown

  • Thread starter Thread starter Ken Birman
  • Start date Start date
K

Ken Birman

Guest
I use reflection fairly heavily and my code has a number of places where I obtain and then call the "invoke" method. When I do this, everything works, but if the invoked code throws an exception the exception details often lack the part of the stack below the invoke. (In contrast if I just pause the application, those same threads show the invoke, show a little dance in unmanaged code, and then you see the stack trace start right up again in whatever I invoked. Breakpoints work too).

So for example, I'll throw a null pointer exception, but I can't interrogate variable values that caused it because the debugger shows the exception as if the .invoke threw it, and doesn't let me crawl the inner stack, even though I do have the inner exception line number in the exception details. So I know what happened and where, but not why.

Is this a Visual studio bug, limitation, or is it because I'm doing something wrong by calling invoke this way? (My use of invoke is to launch callbacks -- preregistered event handles)

Continue reading...
 
Back
Top