2

I have a Windows 10 Universal App that does not include line numbers in the Exception objects .ToString() method.

If I have a method like

private void ThrowException()
{
    try { throw new Exception("Test"); }
    catch (Exception e) { Debug.WriteLine(ex.ToString()); }
}

When I check the output, I don't see the line number where there exception was thrown. I added a Post Build event to the project:

xcopy $(ProjectDir)$(OutDir)*.pdb $(ProjectDir)$(OutDir)AppX\*.pdb

The pdb file is in the Debug folder but not in the AppX folder.

What am I missing? Thanx,

EDIT

I created a new project to test this. I have a single page (MainPage.xaml). Here is the code behind file:

using System;
using Windows.UI.Popups;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;

namespace App2
{
    public sealed partial class MainPage : Page
    {
        public MainPage()
        {
            InitializeComponent();
        }

        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            ThrowException();
        }

        private async void ThrowException()
        {
            try { throw new Exception("Test"); }
            catch (Exception ex) { await new MessageDialog(ex.ToString()).ShowAsync(); }
        }
    }
}

As before, I added the post build event macro:

xcopy $(ProjectDir)$(OutDir)*.pdb $(ProjectDir)$(OutDir)AppX\*.pdb

I compiled in the Release configuration and insured the "Compile with .NET native tool chain" option is checked.

The Appx folder in C:\VS2015\App2\App2\bin\x86\Release\AppX does have the files App2.dll and App2.pdb present.

When I run the app, I get the following in the popup dialog:

System.Exception: Test
  at SharedLibrary!<BaseAddress>+0x122d16

Thanx

EDIT 2

I also tried this in Debug without the native tool chain. In that case, I did not see the pdb file in the AppX folder under Debug

The message in that case was:

System.Exception: Test
  at App2.MainPage.<ThrowException>d_2.MoveNext()

Thanx

user1325543
  • 523
  • 3
  • 12
  • Could you first check the output message when launching the app, for example, mine shows "$(ProjectDir)\bin\x86\Debug\AppX\entrypoint\UwpApp1.exe'. Symbols loaded", it indicated the pdb file is property loaded. – Jackie Jan 17 '16 at 09:20
  • I'm seeing the same issue. I can verify that the pdb files are property loaded. I'm suspecting this is due to the .net core "light-weight" implementation. – Jackie Jan 18 '16 at 01:37
  • FWIW, I did notice in the output window when I ran the app the following entries `'App2.exe' (Win32): Loaded 'C:\VS2015\App2\App2\bin\x86\Release\AppX\App2.exe'. Module was built without symbols.` and `'App2.exe' (CLR Native Compilation v1.0): Loaded 'C:\VS2015\App2\App2\bin\x86\Release\AppX\App2.dll'. Symbols loaded.` Is that relevant? – user1325543 Jan 19 '16 at 03:03
  • Here's a similar post for WinRT app. http://stackoverflow.com/questions/26867558/line-numbers-in-exception-stack-on-winrt – Jackie Jan 19 '16 at 17:02
  • However, I still don't get it to work for UWP app, as you observed too. Unfortunately, UWP Exception class reference the System.Runtime.dll(instead of mscorlib.dll), which is still not open sourced yet. – Jackie Jan 19 '16 at 17:05

1 Answers1

2

I made an error in my original answer and was using immediate window output and not what the code could get from the exception object.

After more research, it looks like this is no longer supported.

See corefx #1420 and related corefx #1797.

Also, there is this reference on SO: How to get StackTrace without Exception in Windows Universal 10 App

Community
  • 1
  • 1
Kory Gill
  • 6,993
  • 1
  • 25
  • 33
  • How is this going to help with the line number info anyway? – Jackie Jan 18 '16 at 07:51
  • Did you try the suggestion? I added details with my observations regarding effect of the check box. – Kory Gill Jan 18 '16 at 08:08
  • I've got no luck with "Compile with .NET Native tool chain" either, maybe I missed something here. Also I wonder how to explain the original post. – Jackie Jan 18 '16 at 08:50
  • Please see my edited post above. I've included the complete MainPage.xaml.cs file contents there. The Native tool chain option didn't help. Thanx. – user1325543 Jan 19 '16 at 02:16
  • Building with .NET Native ToolChain works for me, I'm able to see the line number now. – Jackie Jan 19 '16 at 07:18
  • Those references were over my head I'm afraid. So be it. I can live without line numbers, but they sure would be nice to have. – user1325543 Jan 19 '16 at 08:31
  • @user1325543 Well, it would still be nice to find out the root cause for line number missing for UWP. I'm looking forward to the open source for System.Runtime.dll. – Jackie Jan 20 '16 at 03:48