简体   繁体   中英

Debugging not working in ASP.NET Core, or in VS2017 at all

I am working on a project, and I have two servers, a login server, and a secondary server which serves the application.

The secondary server is ASP.NET Core, but the first one is just ASP.NET MVC, because I couldn't get Identity to work with tokens for Angular 2, in ASP.NET Core. In Visual Studio 2015, breakpoints worked for ASP.NET MVC, but not for ASP.NET Core.

I moved to Visual Studio 2017 in the hope it would fix things. No breakpoints are hit at all, although my A2 project works, the methods are being called.

The debugger says that there's no debug information for the code. I've gone in to project settings and told it to generate the full pdb (at the bottom of build settings, under 'advanced'), I've turned off 'just my code' and turned on .NET code breaks. These are all the suggestions I can find online. My breakpoints are still not being hit.

This might help someone.

When you are debugging in release, breakpoints will not be hit.

Make sure you select debug when you hit F5 or run.

When attempting to debug a .NET Core web application ensure that you have attached to the correct process. I experienced the same issue the OP described when I was attached to the w3wp.exe process.

When I attached to the dotnet.exe process I was able to break as expected.

FYI, this was on a .NET Core 2.0 web application.

The following link is about remote debugging with .NET Core, but parts of it remain applicable.

Remote Debug ASP.NET Core on a Remote IIS Computer in Visual Studio 2017

Brief excerpt from link:

Type the first letter of a process name to quickly find dotnet.exe (for ASP.NET Core). Note: For an ASP.NET Core app, the previous process name was dnx.exe.

Click Attach.

Just change Solution Configurations to Debug mode.

You can see it in the attached image:

在此处输入图像描述

  1. Exit Visual Studio
  2. Right click on the short cut for Visual Studio
  3. Select - Open File Location
  4. Right click on the Visual Studio 2017 file, select Properties
  5. Click on Advanced.
  6. Run As Administrator --> X == On
  7. Apply. OK. OK... blah blah

The following worked for me (Visual Studio 2017):

  1. Open the project properties
  2. Open the Build tab
  3. Click on Advanced...
  4. Set Debugging information to FULL
  5. Clean and rebuild

As I'm working on an API project I had unticked 'Launch Browser' in the project properties. Breakpoints only worked when I ticked this again.

OK, it seems I got a web.config file from somewhere, like this:

   <system.webServer>
    <handlers>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/>
    </handlers>
    <aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false"/>
  </system.webServer>

I don't know how it got here, but if I comment it out, debugging works...

在我的情况下,文件launchSettings.json中的"launchBrowser": true,被意外删除,我把它放回去并且断点被击中。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM