Visual Studio 2015:我无法在发布模式下调试和使用断点 [英] Visual Studio 2015: I can't debug and use breakpoints in Release mode

查看:158
本文介绍了Visual Studio 2015:我无法在发布模式下调试和使用断点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发了一个 UWP应用,该应用使用了许多 NuGet包 MvvmLight,SQLite,... )和其他资源(<同步>控件)。

I have developed an UWP app that uses a lot of NuGet packages (MvvmLight, SQLite, ...) and other resources (Syncfusion controls).

我在 Store 应用中遇到了一个错误已发布用于测试,但当我以 调试模式构建应用程序时不存在。

I encounter a bug with the Store app, which is already published for tests, that is not present when I build the app in "Debug" mode.

因此,我试图在 发布模式下进行调试,并选中 使用.NET Native工具链编译优化代码。构建成功结束,但是在应用程序的主页上遇到Syncfusion控件( SfDataGrid )的异常。我想使用断点来了解会发生什么,但是当我在发布模式下构建应用程序时,它们会被停用。

So, I've tried to debug in "Release" mode, with the checked options "Compile with .NET Native tool chain" and "Optimize code". The build ends successfully, but I encounter an exception with a Syncfusion control (SfDataGrid) on the main page of the app. I would like use breakpoints to understand what happens, but they are deactivated as I build the app in "Release" mode.

如果我构建了处于 调试模式的应用,并选中了相同的选项( 使用.NET Native工具链编译优化代码) ,我在Syncfusion控件上没有遇到相同的错误,并且定义的断点保存得很好。

If I build the app in "Debug" mode, with the same options checked ("Compile with .NET Native tool chain" and "Optimize code"), I don't encounter the same bug with the Syncfusion control, and the defined breakpoints are well keeped.

所以我看不到如何解决我的问题:

So I don't see how I could fix my problem:


  • 如果我创建一个新解决方案并以发布模式构建它,断点保存完好,如果我在发布模式下构建 Syncfusion示例,则可以调试代码

  • ,这是同一件事:断点是保存完好,我可以调试代码

  • 我将应用程序的 build参数与其他应用程序进行了比较:它们是相同的

  • 我还查看了 及时 页面,在Visual Studio中的 选项中。我遇到以下错误: 另一个调试器已将自己注册为即时调试器。要修复,请启用即时调试或运行Visual Studio修复。 。我已经尝试过修复 Visual Studio,但这总是同一件事……

  • if I create a new solution and built it in "Release" mode, the breakpoints are well keeped, and I can debug the code
  • if I build Syncfusion samples in "Release" mode, it's the same thing: the breakpoints are well keeped, and I can debug the code
  • I have compared the "build" parameters of the app and the other ones: they are the same
  • I have also looked at the "Just-in-Time" page, in the Visual Studio "options". I've got the following error: "Another debugger has registered itself as the Just-In-Time debugger. To repair, enable Just-In-Time debugging or run Visual Studio repair.". Ive tried to "repair" Visual Studio, but it's always the same thing...

这里是选项设置:

Here is the "Options" settings:

解决方案中禁用了断点的结果:

And the result in solution, where breakpoints are disabled:

您有什么解释吗?我该如何在发布模式下调试应用?

Would you have any explanation? How could I do to debug my app in "Release" mode?

:进一步添加一些细节调查

我的应用基于 模板(例如Template10,称为 Nentang )。项目的结构是相同的,并且它们共享引用或NuGets包的很大一部分。
但是,如果我将空白 Nentang的构建结果与我的解决方案进行比较,则有一些我不理解的差异:

My app is based on a "template" like Template10, called Nentang. The structure of the project is the same, and they share a big part of references or NuGets packages. But if I compare the build result of the "blank" Nentang and my solution, there are some differences that I don't understand:


  • 如前所述,在我的应用程序上,断点和调试在发布模式下不起作用,并且我可以看到几乎所有模块都没有任何 符号文件

  • as explained, on my app, the breakpoints and debug don't work in "Release" mode, and I can see that almost all modules don't have any "Symbol File":

=>仅将 ntdll.dll KernelBase.dll 链接到本地​​目录中的pdb文件: C:\Users\ myname\AppData\Local\Temp\SymbolCache

=> only "ntdll.dll" and "KernelBase.dll" are linked to thier pdb file in a local directory: "C:\Users\myname\AppData\Local\Temp\SymbolCache"


  • 在空白 Nentang应用程序上,断点并在发布模式下调试良好,并且我可以看到几乎所有模块都有一个 符号文件

  • on the "blank" Nentang app, the breakpoints and debug work well in "Release" mode, and I can see that almost all modules have a "Symbol File":

=> 一半的模块都链接到 项目目录中的同一文件: C:\Projects\Samples ... \Nentang .UWP\bin\x64\Release\AppX\Nentang.UWP.pdb

=> allmost half of the modules are linked to the same file in the "project" directory: "C:\Projects\Samples...\Nentang.UWP\bin\x64\Release\AppX\Nentang.UWP.pdb"

=>模块链接到 系统目录的同一文件: C:\Program Files(x86)\Microsoft SDKs\Windows Kits\10\ \ExtensionSDKs\Microsoft.NET.Native.Framework.1.3\1.3\x64\ret\Native\SharedLibrary.pdb

=> another quarter of the modules are linked to the same file of a "system" directory: "C:\Program Files (x86)\Microsoft SDKs\Windows Kits\10\ExtensionSDKs\Microsoft.NET.Native.Framework.1.3\1.3\x64\ret\Native\SharedLibrary.pdb"

=>其他模块未链接到符号文件: ntdll.dll KernelBase.dll

=> the other modules are not linked to a Symbol File: it's the case of "ntdll.dll" and "KernelBase.dll"

如何恢复项目的符号文件?

How could I restore the "Symbol files" of my project?

I在我的解决方案的属性中还标记了一个奇怪参数,该参数不存在的是Nentang属性:

有此参数: f:\dd\ndp\fxcore\CoreRT\src\System.Private.CoreLib \src\系统\Runtime\ExceptionServices\ExceptionDispatchInfo.cs

I have also remarked a "strange" parameter in the properties of my solution, that is not present is the Nentang properties: There is this parameter: "f:\dd\ndp\fxcore\CoreRT\src\System.Private.CoreLib\src\System\Runtime\ExceptionServices\ExceptionDispatchInfo.cs"

这是什么意思?可以解释我的问题吗?

What does it mean? Could it explain my problem?

推荐答案

调试优化代码始终是一项挑战-甚至更多.NETNative。您可以尝试以下操作:

Debugging optimized code is always a challenge - even more so with .NETNative. Here are a few things you could try:


  • 禁用仅我的代码

  • 禁止JIT优化: 这对于使用.NETNative工具链构建的模块没有帮助。如果在没有.NETNative的发布版本中发生异常,请检查调试器选项 在模块加载时禁止JIT优化(仅受管)。顾名思义,这将导致未优化CLR至JIT的编译代码,这将使您可以设置断点并检查本地变量。

  • 查看输出窗口,以了解出现问题的线索。 。将会出现异常消息,并且前面的消息可能有助于诊断原因。

  • 使用本机调试引擎调试应用程序。您可以通过在项目属性的调试选项卡下选中本机复选框来完成此操作。

  • 最后的方法是调试程序集。

  • Disable Just My Code
  • Suppress JIT Optimizations: This will not help for modules built with .NETNative toolchain. If the exception occurs in Release builds without .NETNative, then check the debugger option called "Suppress JIT optimization on module load (Managed Only)". As the name implies, this will cause the CLR to JIT compile code unoptimized, which will allow you to set breakpoints and inspect locals.
  • Look at the Output window for clues as to what went wrong. The exception message will be there and the preceding messages may help diagnose the cause.
  • Debug your application with Native debug engine. You can do this by checking the Native checkbox under the Debug tab of the project properties.
  • Last resort is to debug the assembly.

这篇关于Visual Studio 2015:我无法在发布模式下调试和使用断点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆