Breakpoints in Visual Studio debugger are not working

When I hover over the circle next to the breakpoint, I get the following message: “The breakpoint will not currently be hit. Unable to find a corresponding location”.
I’ve tried the following solutions:

  • Deleting all files in Library/ScriptAssemblies and restarting Unity (as suggested here)
    -Reinstalling Unity
    -Reinstalling Visual Studio
    -Cleaning and rebuilding my solution in Visual Studio
    -Reverting my project to an earlier version and re-adding the changes I want to make to my project
    After reverting my project, the debugger started working properly, buy after re-adding the changes, the breakpoints stopped working again
    Edit: Also, the compiler is set to debug.

After playing around a little bit, I tried deleting .meta files in my project and changing the Api Compatibility Level setting (in Edit->Project Settings->Player) from “.NET Standard 2.0” to “.NET 4.x”, and this has resolved the issue.

I only changed the Api Compatibility Level setting (in Edit->Project Settings->Player) from “.NET Standard 2.0” to “.NET 4.x” and now it is working!