Christian Findlay
Christian Findlay

Reputation: 7712

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. I ran the project and was able to debug the .NET Standard 2.0 DLL fine. 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.

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. I could then compile and run the project, but debugging the .NET Standard 2.0 Xamarin Forms project does not work at all. Debugging the UWP code does work, and the lower level .NET Standard 2.0 projects do debug. 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. 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?

Upvotes: 7

Views: 2709

Answers (2)

Emil
Emil

Reputation: 6932

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>

Upvotes: 3

Christian Findlay
Christian Findlay

Reputation: 7712

It turns out that there are still issues with debugging .NET Standard 2.0 assemblies in UWP. Apparently there is a new type of PDB that is generated in .NET Standard 2.0 projects. This is related to this bug which has a workaround:

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

It's just a matter of editing the .NET Standard 2.0 project like so:

<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.

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

Some people are still experiencing this issue - even people at Microsoft, so I don't know the status of this at the moment.

Upvotes: 15

Related Questions