Reputation: 1065
We are using MVVMLight with WPF. Our Views & ViewModels reside in different projects. All the unhandled exceptions occurring in Views can be handled by app.xaml.cs file but we would also like to catch the unhandled exceptions from ViewModel by providing some centralized exception handling mechanism instead of writing try..catch in every function. Please suggest something as to how we can achieve the above. Thanks
Upvotes: 3
Views: 1208
Reputation: 20746
Unhandled exceptions from ViewModels can also be handled in App.xaml.cs. There should not be much difference. App.xaml.cs is a central point of your entire application where you handle all the unhandled exceptions.
Side node: I would not recommend you splitting ViewModels and Views into different assemblies for this and other reasons. See my post here describing why.
Upvotes: 5