Cannot load symbols from SDK style C# library while running MVC project

Viewed 56

I have a library that is shared between .NET Core 3.1 and .NET Framework 4.7.2. I have found that when I run the .NET Core 3.1 Azure Function I can debug the library code, but when running the MVC app I cannot. Also, if I try to use intellisense to navigate to definitions within the library it will not take me to the code, but to the meta-data.

I've added a "full" debug type specifier to the top of the Library's csproj file like this and that does not help:

<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
  <TargetFrameworks>net472;netcoreapp3.1</TargetFrameworks>
</PropertyGroup>

<PropertyGroup>
  <DebugType>full</DebugType>
</PropertyGroup>

I have other similar libraries that do not have this issue and have tried copying over some config attributes, but nothing seems to help. How might this be fixed?

I am using the latest version of VS 2019 and I have noticed that the PDB file size has increased since making the DebugType full. If I try to load the symbols manually using the Modules window it tells me a debug file of the correct type cannot be found.

1 Answers

It turns out I had to sign the assembly or give it a guid for my Framework app to navigate into it, or debug it. The csproj looks like this now at the top:

<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
  <ProjectGuid>{<some guid>}</ProjectGuid>
  <TargetFrameworks>net472;netcoreapp3.1</TargetFrameworks>
</PropertyGroup>

<PropertyGroup>
  <DebugType>full</DebugType>
  <SignAssembly>true</SignAssembly>
  <AssemblyOriginatorKeyFile><some snk file name>.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>

The old options to have VS generate the strong signing stuff for you can still be accessed in VS by right-clicking on the project and selecting Properties.

Related