Exception Handling in MVVMLight

We use MVVMLight with WPF. Our Views and ViewModels are in different projects. All unhandled exceptions that occur in the views can be handled by the app.xaml.cs file, but we would also like to catch the unhandled exceptions from the ViewModel by providing some centralized exception handling mechanism instead of writing try..catch in each function. Please suggest something regarding how we can achieve the above. Thanks

+3
source share
1 answer

Unhandled exceptions from ViewModels can also be handled in App.xaml.cs. There should not be much difference. App.xaml.cs is the center point of the entire application where you handle all unhandled exceptions.

Side node: I would not recommend that you separate ViewModels and Views into different assemblies for this and other reasons. See my post here for a description of why.

+5
source

Source: https://habr.com/ru/post/1795953/


All Articles