Reputation: 15330
I am running Silverlight 4 with a MVVM framework. From time to time, but not always, during a detail page load, I get a XamlParseException. Since it works 99% of the time, I'm pretty sure the xaml page is fine.
Is it possible to do something similar to the following in my code behind page?
public DetailView() {
try {
InitializeComponent();
} catch (XamlParseException e) {
Debugger.Break();
}
}
In other words, how do I catch the XamlParseException?
Upvotes: 0
Views: 606
Reputation: 4970
You cannot catch this exception using try-catch when the parsing is being handled by the runtime.
The only way to catch this exception is when you are using XamlReader like in this discussion:
http://social.msdn.microsoft.com/Forums/da-DK/wpf/thread/02679567-1bd3-41d1-bfd1-326f646d95d1You can try handling it on Application_UnhandledException.
More info here: http://msdn.microsoft.com/en-us/library/system.windows.application.unhandledexception(v=vs.95).aspxAnd some more info here: http://msdn.microsoft.com/en-us/library/cc189070(v=vs.95).aspx
Upvotes: 1