VS2019 ,NET Core 5.0 Razor Pages ~ Unable to launch browser could not connect to debug target

I have two .NET Core 5.0 Razor Page Model projects, almost identical, reside in the same solution. Have not been running for almost 4 months.

Now when I wish to make some changes. One of the project cannot run in debug mode. I am always getting the following error

Error when launch with debug

{"tag":"dap.receive","timestamp":1625537078095,"metadata":{"connectionId":0,"message":{"type":"request","command":"launch","arguments":{"WebRoot":"xxxx\ApmtWeb\wwwroot","rootPath":"xxxx\ApmtWeb\wwwroot","__workspaceFolder":"xxxx\ApmtWeb\wwwroot","runtimeExecutable":"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe","runtimeArgs":[],"sourceMaps":true,"url":"","trace":{"logFile":"yyyy\Temp\visualstudio-js-debugger.txt"},"port":54798,"launchUnelevated":false,"projectGuid":"cca052fc-e9e7-44d5-8299-28928d665223","userDataDir":"yyyy\Microsoft\VisualStudio\16.0_e9805624\WebTools\F17440DA_BBDA0153","breakOnLoad":true,"smartStep":true,"skipFiles":[],"showAsyncStacks":true,"timeout":10000,"cleanUp":"onlyTab","name":"Visual Studio launch configuration override","type":"pwa-msedge","request":"launch","continueOnDisconnect":true},"seq":2}},"level":0}

The xxxx and yyyy were obscured due to privacy

My launch settings

"ApmtWeb": { "commandName": "Project", "dotnetRunMessages": "true", "launchBrowser": true, "applicationUrl": "", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } }

I am able to see my web page if I manually type in the URL , before the above error shows and forcing it to shutdown.

There is not such setting inside my entire solution as , and I can't find any reference to 54798 even if I do a global search.

4

3 Answers

When I learned from one of the comments that this is a VS bug, I immediately tried the following:

  1. Close solution
  2. Remove all .vs directories from your project
  3. Launch solution again

Worked for me. Saved me from actually reinstalling VS ;-)

3

You can also disable the debugging of JS by VS, vis the Options menu so you just debug in Chrome (F12). Unchecking this feature, press F5, then stop it, the check it again also fixes the problem.

Such black magic :/ enter image description here

It is not necessary to delete the whole .vs folder, just go to .vs/project/ and delete the debuggerConfiguration -... json file. It is important to close any browser windows that have remained open before running the project again, otherwise it will recreate the debuggerConfiguration -... json file but it still gives an error.

.vs/project/

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like