UWP应用程序的堆栈跟踪中的行号

时间:2016-03-16 21:15:32

标签: c# visual-studio win-universal-app .net-core

我在Visual Studio 2015中创建了一个空白的通用Windows应用程序项目。

我添加了类似的内容:

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

我得到一个堆栈跟踪,如:

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)

即没有行号。

如何显示行号?

1 个答案:

答案 0 :(得分:3)

似乎不再支持此功能。我在这里重新发布我的答案,因为当我在另一个问题上搜索我的答案时,很难在搜索结果中找到它。希望这个问题能帮助人们更轻松地找到这些信息。

参考:windows 10 exceptions not including line numbers

其他信息:

请参阅corefx #1420及相关的corefx #1797

此外,还有关于SO的参考:How to get StackTrace without Exception in Windows Universal 10 App

相关问题