Why does VS2010 always break on exception from MethodInfo.Invoke?
Asked Answered
D

2

5

I have a try/catch around a MethodInfo.Invoke(o,null), and VS2010 is set to never break on Exceptions, but unfortunately the debugger continues to break inside the Invoked method. The method is static, and I've got the Phone Developer Beta installed.

Is this a bug or developer error?

Thx!!

Dominiquedominium answered 27/4, 2010 at 20:11 Comment(0)
D
2

Yes, with every exception check-box is un-checked it breaks on only these Invoke exceptions. All the other exceptions work fine.

The great news is that an anonymous genius gave me a work-around:

delegate void VoidTest(); 
VoidTest test = 
    (VoidTest)Delegate.CreateDelegate(typeof(VoidTest), o, method.Name); 
test(); 

These exceptions do land in the exception handler just as expected! =)

Dominiquedominium answered 4/5, 2010 at 16:26 Comment(0)
M
0

Are you sure that "Break on first-chance exceptions" is disabled? Go to Debug -> Exceptions and make sure everything is turned off.

Montcalm answered 28/4, 2010 at 4:52 Comment(2)
I am having the same problem, and it has nothing to do with this setting. It appears to be a bug in the .NET framework 4.0.Faitour
Me too having same annoying bummer!Mineralize

© 2022 - 2024 — McMap. All rights reserved.