Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Line numbers in exception stack on winRT

We have a project for windows store app using WinRT (and XAML, C#). The problem is, that when some exception is thrown and I log the exception using Debug.WriteLine(ex);, there are no line numbers, so I do not know, where actually was the exception thrown. I have of course DEBUG configuration with "full" symbols set in Project Properties > Build > Advanced > Debug Info.

At first I thougth that it must be something in our project. HOwever, when I downlaoded some samples from microsoft and put there the following code, the exception still does not have line numbers.

        try
        {
            throw new Exception("Test");
        }
        catch (Exception ex)
        {
            Debug.WriteLine(ex);
        }

If I put the code above for example into OnNavigatedTo method, I get:

System.Exception: Test
   at SDKTemplate.MainPage.OnNavigatedTo(NavigationEventArgs e)

No line number there ...

In articles , books etc. there is no mention of the fact, that there should be no line numbers, but maybe I am missing something? Can it be related to version of VS? I am using VS2013. Or some system wide settings?

like image 862
Ondrej Peterka Avatar asked Mar 17 '23 22:03

Ondrej Peterka


1 Answers

What's happening is that Visual Studio isn't including the .pdb file (symbols) in the path where it executes the app. On my machine, the path to the executable looks like this:

C:\Users\msmall\Documents\Visual Studio 2013\Projects\DebugLineNUmbers\DebugLineNUmbers\bin\Debug\AppX

That's where VS packages up the executable and deploys it to the local machine to be run. There's no .pdb file inside the AppX folder. You end up with this:

System.Exception: Test
  at DebugLineNUmbers.MainPage.OnNavigatedTo(NavigationEventArgs e)

However, you can move the .pdb from the Debug folder - just one level up - into the AppX folder and end up with the line numbers:

System.Exception: Test
  at DebugLineNUmbers.MainPage.OnNavigatedTo(NavigationEventArgs e) in
  c:\Users\msmall\Documents\Visual Studio 2013
  \Projects\DebugLineNUmbers\DebugLineNUmbers\MainPage.xaml.cs:line 36
like image 152
Matt Small Avatar answered Mar 24 '23 14:03

Matt Small