To debug MvvmCross issues effectively, you need to configure your exception settings in Visual Studio. Here's a step-by-step guide on how to do this:
1. Enable Source Server Support
Before diving into exception settings, ensure that you can step through MvvmCross code using GitLink. This allows you to debug into MvvmCross sources without manually downloading them.
- Enable Source Server Support: Go to `Tools > Options > Debugging > General` and check the box next to `Enable source server support`. This allows Visual Studio to fetch the source code from the MvvmCross GitHub repository when debugging[5].
2. Configure Exception Settings
To catch exceptions that might be thrown by MvvmCross, you need to configure Visual Studio to break on these exceptions.
- Open Exception Settings: In Visual Studio, go to `Debug > Windows > Exception Settings`. This opens the Exception Settings window where you can manage which exceptions the debugger breaks on[4].
- Enable Breaking on Exceptions: In the Exception Settings window, expand the Common Language Runtime Exceptions category. Check the boxes next to any exceptions you want the debugger to break on. For comprehensive debugging, you might want to enable all exceptions under this category[7].
- Search for Specific Exceptions: If you're looking for a particular exception, use the search bar at the top of the Exception Settings window. This helps you quickly find and enable breaking on specific exceptions.
- Add Conditions: If needed, you can add conditions to exceptions. Right-click an exception and select Edit Conditions. This allows you to specify under which conditions (e.g., specific modules) the debugger should break on the exception[4].
3. Debugging MvvmCross Issues
Once your exception settings are configured:
- Start Debugging: Begin debugging your application. If an exception occurs within MvvmCross, the debugger will now break at the point where the exception is thrown, allowing you to inspect variables and step through the code[7].
- Step Through MvvmCross Code: With source server support enabled, you can step into MvvmCross code directly from your application. This helps in diagnosing issues that might be hidden within the MvvmCross framework[5].
4. Handling Unhandled Exceptions
If you want to catch all unhandled exceptions in your Xamarin Android app using MvvmCross, consider implementing a global exception handler. This can be done by overriding the `OnCreate` method in your main activity and setting up an unhandled exception handler[3].
By following these steps, you can effectively debug MvvmCross issues by configuring exception settings and stepping through the MvvmCross source code when needed.
Citations:[1] https://learn.microsoft.com/en-us/answers/questions/1182901/how-to-enable-the-exception-setting-option-in-debu
[2] https://stackoverflow.com/questions/21029462/debugging-mvvmcross-application-in-xamarin-studio-with-mvvmcross-sources
[3] https://stackoverflow.com/questions/47306092/xamarin-mvvmcross-unhandled-exceptions
[4] https://learn.microsoft.com/en-us/visualstudio/debugger/managing-exceptions-with-the-debugger?view=vs-2022
[5] https://www.mvvmcross.com/documentation/contributing/debugging-with-symbols
[6] https://www.mvvmcross.com/documentation/fundamentals/data-binding
[7] https://nicksnettravels.builttoroam.com/post-2018-07-31-debugging-and-contributing-to-mvvmcross-aspx/
[8] https://devblogs.microsoft.com/xamarin/demystifying-build-configurations/