I am new to WPF, I am using VS2010 beta2, .NET 4.0.
Throw new Exception("test") in my code simply swallows exception and application does not crash.
This is not what I expect, I want the application to crash if unhandled exception occurs.
Is there a simple way to achieve this?
Also, neither Application.DispatcherUnhandledException nor AppDomain.UnhandledException is executed. It is probably because all code is executed as part of the data binding (I am using MVVM pattern and exception is thrown in ViewModel constructor).
While debugging I can look into Output window and find out what is wrong. But it seems to me odd, that application simply ignores error, leaves UI in incorrect state and does not crash.
Edit:
It seems that maybe only non-critical binding exceptions should occur while databinding. Maybe extracting functionality which is not directly related to binding (for example connecting to database) out of the binding execution can be the solution. However I am not sure how to achieve it in MVVM.
Simplified example:
XAML:
<DataTemplate DataType="{x:Type vm:ItemViewModel}">
<vw:ItemControl />
</DataTemplate>
<ContentControl
Content="{Binding Path=MyItem}"
/>
where MyItem creates and returns instance of ItemViewModel. Problem is that constructor of ItemViewModel is executed as part of the data binding and I am not sure if this is good practice (this constructor contains code which can fail - for example if database is not accessible).