Sunday, May 31, 2015

Wolf he cries! Internal handled exceptions in Xamarin Forms

Edit: According to my connections to NSA, I've heard that this specific case will be reviewed to avoid throwing of an exception.

Consider the following:

<Image Source="{Binding ImageUrl}" />

ImageUrl is a string pointing to an image, like


When you run this through Visual Studio with the debugger attached and break on all exceptions you get a System.InvalidCastException. The exception itself is handled internally and only visible if you break on all exceptions.

But, how is this an exception? Isn't it expected that the source might be a string? It's not an exception from the normal program flow in my opinion? Couldn't there just be a check of the type passed in and if the type is faulty, THEN throw an exception? String as a source IS valid.

Right now it's a pain to enable break on all CLR exceptions since you hit so many handled exceptions. And sometimes you need that option enabled...

It's a case of "Wolf he cries"... 

Any thoughts on this? Am I totally wrong?

No comments:

Post a Comment