I am using Visual Studio 2017. I created a .NET Standard library (let this library be Lib1) project with two Target frameworks, netstandard2.0 and net46. Then I have another two projects... one is a "pure" .NET Framework 4.6 console project (lets call it Console46) and a .NET Core console project (lets call it ConsoleCore). Both of them reference Lib1.
When I run the ConsoleCore project, I can debug and put breakpoints without any problem, but when I run Console46, Visual Studio can not load the pdb file, so I can't debug the library, put breakpoints, etc.
I try to load the PDB file manually because it is created for the net46, but it fails also.
What can I do to fix this problem?
Thank you!
To specify symbol locations and loading options: In Visual Studio, open Tools > Options > Debugging > Symbols (or Debug > Options > Symbols).
From Visual Studio, select Tools > Options > Debugging. Select Symbols from the list, and then select the + sign to add a new Azure DevOps symbol server location.
By default, Visual Studio Code launch settings use the Debug build configuration, so you don't need to change it before debugging. Start Visual Studio Code. Open the folder of the project that you created in Create a . NET console application using Visual Studio Code.
The answer @hans-passant posted in the comments is a good solution.
I rebuilt my .NET-Core libraries with this option in the csproj file. The following is a snippet that gets added to the csproj when you modify the file as per @hans-passant's instructions (Project > Properties > Build tab > Advanced button. Change the "Debugging information" combobox from Portable to Full):
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DebugType>full</DebugType>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>
I then dumped the built dll
and pdb
into the bin
directory of my .NET-Framework application and I was able to step into my .NET-Core code.
Here's a successful workaround for something very much similar to what you describe. When my 'Solution' contained only .NET Standard projects and I attempted to Debug using an external 4.6.1 Framework executable (let's call it "Foo.exe" from a separate solution) my breakpoints weren't hitting either.
My understanding is that there are two distinct debuggers, the .NET Core Debugger and the Full Framework Debugger. My vs 'Solution' defaulted to the former since that's the only type of Project that was in it.
What eventually worked for me was tricking VS2019 into using the Full Framework Debugger.
To do this, I added a placeholder 4.6.1 Framework console project to the solution and set it as the Startup project. In the Debug tab I set the Start Action exactly the same, pointing the value in Start External Program to the same one as before ("Foo.exe"). Now the breakpoints work.
NOTES for clarity:
BTW setting the "Build\Advanced\Debugging information" to 'Full' as described in the earlier posts made no difference in my scenario but THANK YOU it made sense and was sure worth a try!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With