简体   繁体   English

无法在UWP中调试.NET Standard 2.0 DLL

[英]Can't Debug .NET Standard 2.0 DLL in UWP

I created a fresh Xamarin Forms solution, upgraded all the NuGets, made sure that the UWP version was targeting build 16299, and made sure the .NET Standard project is targeting 2.0. 我创建了一个新的Xamarin Forms解决方案,升级了所有NuGets,确保UWP版本的目标是构建16299,并确保.NET Standard项目的目标是2.0。 I ran the project and was able to debug the .NET Standard 2.0 DLL fine. 我运行该项目,并能够很好地调试.NET Standard 2.0 DLL。 You can download this here but I don't think it will be of any use: https://www.dropbox.com/s/jw13heu98yq2n6x/CleanXF.7z?dl=0 . 你可以在这里下载,但我认为它没有任何用处: https//www.dropbox.com/s/jw13heu98yq2n6x/CleanXF.7z?dl = 0

I then pulled these projects in to another solution, added some references to other projects, and copied and pasted some Xamarin Forms pages etc. in to the new clean projects. 然后我将这些项目拉到另一个解决方案中,添加了一些对其他项目的引用,并将一些Xamarin Forms页面等复制并粘贴到新的清洁项目中。 I could then compile and run the project, but debugging the .NET Standard 2.0 Xamarin Forms project does not work at all. 然后我可以编译并运行该项目,但调试.NET Standard 2.0 Xamarin Forms项目根本不起作用。 Debugging the UWP code does work, and the lower level .NET Standard 2.0 projects do debug. 调试UWP代码确实有效,而较低级别的.NET Standard 2.0项目会进行调试。 It's only one project that won't debug. 它只是一个不会调试的项目。 I have already tried Git cleaning the folders again and again to ensure that rebuilds are happening. 我已经尝试过Git一次又一次地清理文件夹以确保重建正在进行。 I have also tried creating the project from scratch and adding all the files back in. Again, it compiles and runs, but doesn't debug. 我也尝试从头开始创建项目并重新添加所有文件。再次,它编译并运行,但不调试。

What things can I try to get debugging working? 我可以尝试哪些方法来调试工作?

It turns out that there are still issues with debugging .NET Standard 2.0 assemblies in UWP. 事实证明,在UWP中调试.NET Standard 2.0程序集仍然存在问题。 Apparently there is a new type of PDB that is generated in .NET Standard 2.0 projects. 显然,在.NET Standard 2.0项目中生成了一种新类型的PDB。 This is related to this bug which has a workaround: 这与此错误有关,它有一个解决方法:

https://github.com/dotnet/sdk/issues/955 https://github.com/dotnet/sdk/issues/955

It's just a matter of editing the .NET Standard 2.0 project like so: 这只是编辑.NET Standard 2.0项目的问题,如下所示:

<PropertyGroup>
    <DebugType>pdbonly</DebugType>
</PropertyGroup>

This switches to old school PDBs and will slow down debugging, but until MSBuild etc. catches up, it's the only way to solve the problem from what I can see. 这会切换到旧学校的PDB,并会减慢调试速度,但是直到MSBuild等赶上来,这是从我能看到的问题解决问题的唯一方法。

Edit: Microsoft claim that the original bug is now fixed in the latest version of Visual Studio, but I have not confirmed this: https://github.com/Microsoft/UWPCommunityToolkit/issues/1951 编辑:Microsoft声称原始错误现在已在最新版本的Visual Studio中修复,但我还没有确认: https //github.com/Microsoft/UWPCommunityToolkit/issues/1951

Some people are still experiencing this issue - even people at Microsoft, so I don't know the status of this at the moment. 有些人仍然遇到这个问题 - 即使是微软的人,所以我现在还不知道这个问题。

alternative solution to accepted solution, you use also below lines. 接受解决方案的替代解决方案,您也使用下面的线。 it tells that use full debugging, symbols included only for debug mode. 它告诉我们使用完全调试,仅包含用于调试模式的符号。 I am not sure if Melbourne developers answer is affecting release mode, just to ensure. 我不确定墨尔本开发人员的回答是否会影响发布模式,只是为了确保。

 <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
    <DebugType>full</DebugType>
    <DebugSymbols>true</DebugSymbols>
  </PropertyGroup>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM