8

I created a blank Universal Windows App project in Visual Studio 2015.

I add something like:

try {
    string foo = null;
    int len = foo.Length;
} catch (Exception ex) {
    System.Diagnostics.Debug.WriteLine(ex);
}

I get a stack trace like:

Exception thrown: 'System.NullReferenceException' in TestStackTraces.exe
System.NullReferenceException: Object reference not set to an instance of an object.
at TestStackTraces.App.OnLaunched(LaunchActivatedEventArgs e)

i.e., No line numbers.

How do I get line numbers to show up?

Kory Gill
  • 6,993
  • 1
  • 25
  • 33
steve hannah
  • 4,586
  • 11
  • 18
  • Take a look at this answer: http://stackoverflow.com/questions/3328990/c-sharp-get-line-number-which-threw-exception – Troels Larsen Mar 16 '16 at 22:40
  • @TroelsLarsen, Actually, on WIn10/UWP this is no longer supported. http://stackoverflow.com/questions/34833573/windows-10-exceptions-not-including-line-numbers – Kory Gill Mar 17 '16 at 05:40
  • 1
    It is because of the U in UWP. Being Universal means you target the .NETCore version of the CLR, currently CoreCLR. It is much smaller and thus easier to port to different platforms. Both contribute to the missing feature, you don't have the COM component that can read the line number info from the PDB file at runtime. Diasymreader.dll in the desktop version of the CLR. That nobody in the corefx team seems to know this is, well, a bit scary. A lot of foundational knowledge has been lost at Microsoft, turn-over has been high, maybe they should ask more SO questions :) – Hans Passant Mar 17 '16 at 06:15

1 Answers1

8

This appears to be no longer supported. I am re-posting my answer here, because when I did a search for my answer on another question, it was very difficult to find it in the search results. Hopefully this question will help people find this info easier.

Reference: windows 10 exceptions not including line numbers

Other info:

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