MAUI Exception Line Numbers / Debug Symbols

Chris Turk 1 Reputation point
2023-01-09T19:34:49.977+00:00

When I log an exception in my MAUI App (Android), the stacktrace doesn't contain line numbers (only if the debugger is attached!). I need stacktrace line numbers in release builds without attached debugger.
Is this still not possible? / do I still have to use use mono-symbolicate to convert stacktraces? https://github.com/xamarin/release-notes-archive/blob/master/release-notes/android/xamarin.android_7/xamarin.android_7.4/index.md#file-name-and-line-number-information-in-release-builds)

MainPage.xaml.cs (new MAUI App from default template)

        private void OnCounterClicked(object sender, EventArgs e)  
        {  
            try  
            {  
                throw new Exception("test");  
            }  
            catch (Exception ex)  
            {  
                Console.WriteLine("Exception: {0}", ex);  
            }  
        }  

Output with debugger
01-09 20:12:28.740 31662 31662 I DOTNET : Exception: System.Exception: test
01-09 20:12:28.740 31662 31662 I DOTNET : at ExceptionLineNumberTest.Maui.MainPage.OnCounterClicked(Object sender, EventArgs e) in /Users/xxxx/Projects/ExceptionLineNumberTest.Maui/ExceptionLineNumberTest.Maui/MainPage.xaml.cs:line 27

Output without debugger
01-09 20:13:07.055 32175 32175 I DOTNET : Exception: System.Exception: test
01-09 20:13:07.055 32175 32175 I DOTNET : at ExceptionLineNumberTest.Maui.MainPage.OnCounterClicked(Object sender, EventArgs e)

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
904 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Yonglun Liu (Shanghai Wicresoft Co,.Ltd.) 11,461 Reputation points Microsoft Employee
    2023-01-11T05:18:04.6633333+00:00

    Yes, you need to symbolicate your log file to get the exception line numbers.

    In addition, you could try to use this .Net CLI dotnet-stack to do it on .Net 6 and 7 applications.

    Please refer to Inspect managed stack traces to get more details.

    Best Regards,

    Alec Liu.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our [documentation][1] to enable e-mail notifications if you want to receive the related email notification for this thread.

    No comments