My company is giving us new virtual machines for .NET development and I’m trying to set them up. Problem is, the dotnet debugger doesn’t seem to work, and I cannot figure out why.
Some specs:
OS: Windows 10 22H2
VS: Visual Studio Professional 2022 17.8.3, workload wise c# and c++ desktop development, and MAUI are installed
dotnet sdks: 8.0.100 and 8.0.403
When I create any c# project, for example a simple Hello World!
console application, the project compiles correctly, it runs, however break points won’t be hit. After starting the break points will be deactivated and display the error message: "The breakpoint will not currently be hit. No symbols have been loaded for this document"
I’ve tried building and debugging from Visual Studio Code as well, using the dotnet CLI. The break points are displaying the same error message.
The error message usually means that no .pdb file was found, however cheking the file system the .pdb file is there, right next to the .exe file. Even stranger, if I check the Debug->Windows->Modules window while the application is running no modules appear there. The modules window is just empty.
I have verified multiple times, that I am in debug mode. I’ve tried building with AnyCpu, X64 and X86 as well, nothing changed.
I’ve verified, that Optimize Code is turned off (even for Release).
I’ve turned "Suppress jit optimization on module load" on, but it did not help.
I’ve tried "Enable just my Code" neither off, or on worked.
I have tried Clean->Rebuild, I’ve tried deleting the obj and bin folders, I’ve tried deleting the .vs folder. I’ve tried restarting Visual Studio, and I’ve tried rebooting the Virtual Machine. None them worked.
I’ve tried creating projects on both the C and D drives. No difference.
I’ve tried changing the debug symbols in Project Properties->Build->General. No difference.
Debugger.IsAttached
returns false. Debugger.Launch()
and Debugger.Break()
crashes the application with an error code that says no debugger was found ((process 8476) exited with code -2147483645.).
I should mention, Visual Studio appears as if the debugger has started, the diagnostic tools come up and I can "detach" the debugger etc.
I tried enabling mixed mode debugging via Debug Properties->Enable Native Code debugging. With this set to true, if I check the modules window, the native modules are there, loaded correctly. Since I’ve enabled downloading from symbol servers, their symbols are loaded with the message: "Symbols loaded without source information".
However, the managed symbols have some problems. First of all, they display an error message: "The module did not load at the default load address". As for the symbols it says: "Native debugger skipped loading symbols for managed module." The Load Symbols button is missing. I don’t know what is going on, but to me it seems like the native debugger started correctly, however the managed debugger did not.
If I change the code, it compiles, and I can see the change in the running application.
2
Answers
There are many lists to check if everything is correctly configured. Here is my checklist. Maybe you checked some of them already.
Uncheck the "Enable Just My Code" option under Tools => Options => Debugging => General
When the breakpoints clicked by the mouse are invalid, you can perform the following operations in vs: Debug –> delete all breakpoints Debug –> New Breakpoint –> Function Breakpoint, and then enter the name of the function to add a breakpoint
remove the folder ‘.vs’ next to the solution file ‘.sln’ and all the files in folder ‘debug’ and rebuild
Here is a similar question you could refer to
You can specify the code type the debugger should load symbols for in the “Attach to Process” dialog, ensuring it loads the necessary .pdb symbol files correctly. Here are the specific steps to follow:
“Attach to” option.
e.g. Managed v4.0 and/or native.