简体   繁体   中英

Why the debugger doesn't work

My debugger is not working,
I'm putting a breakpoint, but in run, time visual studio doesn't stop on the breakPoint.
How to fix it?
There is nothing special in my application, it is a simple web application. I am using visual studio 2005.

I've created a new web application project, and on the default.aspx page there is a obout grid control, on the default.cs i am filling a datatable and putting it as datatasource for the grid.
I was able to debug it, suddenly the debugger is never hit.
note that the debugger is on the load event.

Find below the steps that solved my problem:

  1. Delete ASP.NET temporary files from C:\\Windows\\Microsoft.NET\\Framework\\v2.0.50727\\Temporary ASP.NET Files
  2. Change build configuration to debug from project properties.
  3. Delete bin folder from your project.
  4. Check if compilation debug is set to true in the web.config
  5. iisreset
  6. Rebuild the project.

There are a couple of things that could be wrong:

  • Your source code and assembly could be out of sync - rebuild the application and try again.
  • You could be attached to the wrong process - check to see what process you are attached to.
  • There could be a logical error in your code that is causing your breakpoint to not be hit (ie the method you are in is not actually called, logical branching is routing control around the breakpoint, etc.)

Break point was not getting hit, i cleaned and rebuild, but still not hitting,

I just reopened the page (In my case Controller) and started working fine ..

The symbols probably aren't loaded, that's why the breakpoint won't be hit. Did you set the website as the startup project?

When debugging, what process it attached? It should be w3wp.exe if you want to debug asp.net code.

You might need to set your application in web config so that it can be debugged..

<system.web>
    <!-- 
        Set compilation debug="true" to insert debugging 
        symbols into the compiled page. Because this 
        affects performance, set this value to true only 
        during development.
    -->
    <compilation debug="true">
        <assemblies>
            <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
            <add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
            <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
            <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
        </assemblies>
    </compilation>

When everything failed try this: Right mouse button on your project -> Build -> untick 'Optimize code'

Or

I had similar problems when I've installed dotPeek and maybe because I don't have Resharper it was loading symbols from dotPeek symbol server but it couldn't hit my breakpoint. In that case Open dotPeek and click on Stop Symbol Server.

You need to be running in Debug mode, and not Release mode.

Here's a detailed article about How to: Enable Debugging for ASP.NET Applications Basically, you can either set debug mode in project properties or in web.config.

尝试取消选中项目属性中的“启用 Visual Studio 托管进程”-> 调试对我有用

做一个Clean Project ,并确保您单击Debug ,而不是Run

This can occur when Visual Studio is set to debug Managed code but the code is not managed (managed code is running under the control of the common language runtime (CLR)).

To fix the problem change the debug mode as shown in the right hand side of the figure below to Native only , Mixed , or Auto . 在此处输入图片说明

Side note: I recommend not choosing Mixed unless your system has both managed and native code (code that does not run under the CLR) because Visual Studio can't attach to an already running process in mixed mode. To debug an already running code Visual Studio need to be set to debug in Native only or Managed only .

I've seen the already existing answers have listed many possible causes, but I'd like to add one more: if you're using post-compilation tools (such as ILMerge), check whether those tools keep your debugging information (is there a .pdb file? or maybe you have embedded it in your compilation output). For those ones who are actually using AfterBuild tasks in their .csproj I really suggest to check out.

You can enable Debug as below steps.

1) Right click project solution
2) Select Debug( can find left side)
3) select Debug in Configuration dropdown.

Now run your solution. It will hit breakpoint. 在此处输入图片说明

I had the same issue on Visual Studio 2019 only o realize that when I set the web project as a startup project, VS didn't automatically set the Default page. I had to manually set my Default.aspx as the startup page and this solved my issue.

Are you debugging using IIS Express instead of IIS Local. I found IIS Express sometime won't hit debug points, IIS Local works fine.

You could be like me to have both a production version (installed via a msi file) and a development version (opened in Visual Studio), and that is why I cannot get some of my breakpoints in the VS triggered today.

If that is the case you need to uninstall the production version as I think some of the dll files are interfering with my debugging session.

Clean and Rebuild your solution afterwards should fix the issue.

In Visual Studio 2010

  1. Select Build > Clean {Project Name}
  2. Rebuild Project

Now Try to rebuild project and try debug

All the best

After installing following add-on it started working. After installing, restart visual studio once. Install plug-in as per VS version.

https://download.qt.io/official_releases/vsaddin/

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