问题描述
我们有一个使用WinRT(和XAML,C#)的Windows商店应用程序的项目。问题是,当抛出一些异常时,我使用 Debug.WriteLine(ex);
记录异常,没有行号,所以我不知道,在哪里实际上是抛出的异常。我在课程属性>构建>高级>调试信息中设置了完整符号的DEBUG配置。
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);
}
如果我把代码放在 OnNavigatedTo
方法,我得到:
If I put the code above for example into OnNavigatedTo
method, I get:
System.Exception: Test
at SDKTemplate.MainPage.OnNavigatedTo(NavigationEventArgs e)
没有行号...
在文章,书籍等中,没有提到事实,应该没有行号,但也许我错过了什么?它可以与VS的版本相关吗?我在使用VS2013。或一些系统范围的设置?
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?
推荐答案
发生了什么事情是Visual Studio不包括.pdb文件执行应用程序的路径在我的机器上,可执行文件的路径如下所示:
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
C:\Users\msmall\Documents\Visual Studio 2013\Projects\DebugLineNUmbers\DebugLineNUmbers\bin\Debug\AppX
这是VS打包可执行文件并将其部署到本地计算机以运行的地方。 AppX文件夹中没有.pdb文件。你最终这样做:
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)
但是,您可以将.pdb从Debug文件夹移动到AppX文件夹最后使用行号:
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
这篇关于winRT上的异常堆栈中的行号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!