问题
I'm very new to Visual Studio Code. I'm trying to debug an application that exists already that I've cloned via Git. None of my files are modified yet. I've downloaded the microsoft extension "C# for Visual Studio Code (powered by OmniSharp)". The application starts and it brings me to the home page (http://localhost:5000/). However it didn't stop at my breakpoints within startup.cs
When I look at the application while its running instead of being a red bullet point its a hollow gray breakpoint. Hovering over it tells me "The source code is different from the original version. To allow this breakpoint to be hit: Add "requireExactSource":false to launch.json and restart debugging.". I can't understand this.
I'm using:
- Visual Code 1.17.1
- Shell 1.7.7
- renderer 58.0.3029.110
- node 7.9.0
- architecture x64
I'm also using dotnet version 1.0.3
回答1:
This happened to me when I upgraded my project from .NET Core 2.0 to 2.1. The problem was that I forgot to edit launch.json
to change the binary path from netcoreapp2.0 to netcoreapp2.1 so VS Code was looking for binaries in the wrong place. Editing the path fixed the problem.
回答2:
This could happen for several reasons, in my case it was a simple/dumb mistake, I created a solution in my main folder, then I added a new folder and created a webapp in it. I configured launch.json and task.json and it worked fine until I tried to debug a modification.
My problem was that I forgot to add the webapp project to the solution, so it failed when the solution tried to build it.
So the solution for me was to add my project to the solution.
If this is not your case try to figure out why your project is not being built, or why it is pointing to other directory.
回答3:
I am kind of new with Visual Studio Code as well and I faced the same issue. Luckily, I was able to sort it out.
First of all, while I was in Debug mode Visual Studio Code gave me the right hint, which is the one that you mentioned:
Breakpoint warning: The source code is different from the original version. To allow this breakpoint to be hit: Add '"requireExactSource": false' to launch.json and restart debugging. -
So, in order to understand, I suggest you read thisVisualStudioCode-LaunchConfigurations
As the documentation in the link above states:
The launch.json file located in a .vscode folder in your workspace (project root folder) or in your user settings or workspace settings.
So, if you edit that file and do what the debug hint explains, that's:
Add '"requireExactSource": false' to launch.json and restart debugging. -
My launch.json now looks like this:
configurations": [
{
"name": ".NET Core Launch (web)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/DotNetCoreAngularAPp/bin/Debug/netcoreapp2.1/DotNetCoreAngularApp.dll",
"args": [],
"cwd": "${workspaceFolder}/DotNetCoreAngularAPp",
"stopAtEntry": false,
"requireExactSource": false,
The last line shows the statement added. Now, you should be able to debug it. I hope this help.
回答4:
This is a follow up to the accepted answer on the occasion of upgrading a razor web app from .Net Core 3.0 to 3.1:
- Change the .csproj file /Project/PropertyGroup/TargetFramework to netcoreapp3.1
- as earlier mentioned: change the launch.json configurations[0].program to workspaceFolder/bin/Debug/netcoreapp3.1/MyApp.dll
- Delete the netcoreapp3.0 and netcoreapp3.1 folders from workspaceFolder/bin/Debug/
- in the terminal: dotnet build
- F5 to debug and breakpoint gets hit
来源:https://stackoverflow.com/questions/46693211/visual-studio-code-breakpoint-warning-the-source-code-is-different-from-the-ori