The uncatchable exception
Posted
by chaiguy
on Stack Overflow
See other posts from Stack Overflow
or by chaiguy
Published on 2010-06-16T01:05:35Z
Indexed on
2010/06/16
1:12 UTC
Read the original article
Hit count: 369
Another custom MarkupExtension binding question...
This time, my converter is being called before DataContext is set on the target element. This isn't a big deal because it will get updated when DataContext eventually receives a value. What is causing problems is the NullReferenceException I'm getting because of DataContext being null.
Even though I'm attempting to catch the exception in my value converter:
try {
return ( (MethodInfo)_member ).Invoke( parameter, null );
} catch {
return Binding.DoNothing;
}
For some reason the debugger is still halting at this point.
Now I'm thinking it could be because the exception is happening in another assembly from where it is being caught (I'm trying to package this in a reusable class library, and _member above points to a method in the application assembly).
If I run my little test app without the debugger it works fine, however my application is a little more robust and has general exception handling which is getting triggered because of this.
I'm wondering if there is just some attribute or something (or perhaps some reflection parameter I'm missing?) I can use to make the exception be caught like it's supposed to.
© Stack Overflow or respective owner