I am new to Wpf using MvvmCross. I have been using MvvmCross for WindowsPhone App for a while now and exception handling isn't that hard because I can use the default App.xaml.cs and its UnhandledException
event. However, in a WPF project, the App.xaml.cs file is empty so whenever one of my ViewModels encounters an exception, it crashes because I don't know where to handle exceptions.
How can I fix this?
You should be able to use UnhandledException in a similar manner to your Windows Phone App.
As explained by Stuart for WPF here , under "Modify the App.xaml.cs to Use Setup", you should have a DoSetup method in App.xaml.cs.
You can then add event handlers something like this:
DispatcherUnhandledException += OnDispatcherUnhandledException;
AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException;
TaskScheduler.UnobservedTaskException += TaskSchedulerOnUnobservedTaskException;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.