How to debug reason for Crash in .NET MAUI Release App

May 2024 ยท 3 minute read

Finally, I could deploy my App in Release-Mode on my own iPhone.

I played around with my different Views which can be reached by clicking on a Tab at the Bottom (Sharpnado Tab). I also added/deleted Items within my App. So far so good and it worked as expected.

After having deleting all my Items, I could still work with my App. But then, it somehow crashed by clicking on the 2nd Tab to show the 2nd View.

After this crash, I couldn't click on the 2nd Tab anymore without getting the Crash again. It crashes so hard that the App is closed every time. When I restarted my App, I still can't click on the 2nd Tab to show the View, anymore. Even restarting my iPhone does not help. It still crashes every time when I click on the 2nd Tab.

For me that is a worst case scenario thinking about a deploy. I never ever had a crash navigating to this View while I was using my App in any of the iOS Simulators.

Question for me is, how can I find out what is wrong and where this crash actually comes from? Are there any recommendations, how I can find out what the actual problem is when this happens again?

2

1 Answer

Have a peek through the log files to find the error, or, if that doesn't work, try putting try and catch blocks throughout your code in areas that are suspected to cause the error(s) (like the view switching sections). Have the catch blocks just send a notification containing the error message and some details.

Follow these steps to find the logs:

  • Open Visual Studio if you haven't already (I'm assuming you're using that as that's the standard for .NET MAUI). It should look something like this:
    Screenshot of Visual Studio

  • Now run the application. Wait until this operation is complete before continuing.

  • Now press Ctrl + Q or click on the Search button at the top of the window. A dialog should show, like the following:
    Dialog

  • Make sure the "Feature Search" tab (in the dialog) is selected and then type "output" into the search bar. Click on the top result, which should look like the one shown in the bottom picture:
    Click on this option

  • Now, at the bottom of your Visual Studio window (provided you haven't messed around with the layout), you should see a section titled "Output". Make sure "Debug" is selected in the drop down menu right below the title, and see if you see any errors there. This is what it should look like (exclude the actual text contents of the Debug pane, that's for another specific application I'm developing):
    Visual Studio screenshot

  • Now see if you can trigger the error, if it already hasn't occurred. It should appear in the Output pane, along with some details.

  • As a side note: I can't really answer your question that well because you need to put relevant pieces of code in your question. We don't know what the error is or have much context. Please update your question with more details and I'll try to help.

    8

    ncG1vNJzZmirpJawrLvVnqmfpJ%2Bse6S7zGiorp2jqbawutJobnBsYmd%2BcoSOoaawZaSkeqWxwa6eZqqVlsCwuoyfpqtlk6eutLSMoqVmppWpeq6t1KJkq52cmq60sYyap6k%3D