Why the debugger doesn't work
Asked Answered
K

19

29

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.

Keppel answered 10/3, 2010 at 13:3 Comment(3)
Is it running debug mode? Is Visual Studio attached to the web server?Immemorial
Is your breakpoint active? (active = full red circle) or inactive? (inactive = empty red circle)Twerp
I am using C#, and the breakpoint is active.Keppel
K
26

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.
Keppel answered 10/3, 2010 at 14:13 Comment(1)
Very good, one more thing I would like to add is: after I've done everything as described it still was not working here. The other step I've made was deleting the SOLUTIONNAME.suo and worked!Kellykellyann
A
11

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 (i.e. the method you are in is not actually called, logical branching is routing control around the breakpoint, etc.)
Admissive answered 10/3, 2010 at 13:5 Comment(4)
+1: Logic Errors are the most common reason for "debugger is not working"Broddy
I've rebuilt my project, and i am not attaching the debugger to any process. It is a project with only one page and i have a code on load event, and there is no references or other projects added!!!Keppel
Can you edit your question to provide a step-by-step breakdown of exactly what you are doing? There are several potential points of failure and if you give us a complete breakdown we will be able to better help. :)Admissive
Put a breakpoint on the first line of your page_load event and see if it gets hit.Marduk
S
4

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 ..

Soapwort answered 7/6, 2016 at 10:30 Comment(1)
Thanks! I was expecting that the answer Gaby would fix it, but actually yours did!. When I reopened the page the breakpoint was gone but when I readded it worked again. Thanks!!Fleuron
C
3

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.

Cadmarr answered 16/1, 2017 at 16:41 Comment(0)
R
2

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.

Rayraya answered 10/3, 2010 at 13:5 Comment(1)
It might not be w3wp.exe if they are testing with Cassini.Admissive
L
2

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>
Leonoraleonore answered 10/3, 2010 at 13:7 Comment(0)
W
2

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.

Wappes answered 10/3, 2010 at 13:11 Comment(0)
P
0

try uncheck "Enable the Visual Studio hosting process" that in project properties -> debug worked for me

Premium answered 9/7, 2012 at 12:25 Comment(0)
H
0

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. enter image description here

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.

Haas answered 20/5, 2017 at 22:19 Comment(0)
M
0

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.

Magnetics answered 16/1, 2019 at 17:0 Comment(0)
Z
0

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. enter image description here

Zipah answered 22/8, 2019 at 10:4 Comment(0)
R
0

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

Reconcilable answered 4/2, 2020 at 2:23 Comment(0)
C
0

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.

Constrictive answered 4/11, 2020 at 17:12 Comment(0)
O
0

if you are using publish and IIS, then check your Publish configuration, make sure it says Debug

Go to publish window [1]: https://i.sstatic.net/X9Dke.png

Opposite answered 14/2, 2023 at 19:7 Comment(0)
S
0

I had a .net standard project which I had its output type set to ConsoleApplication. Well, such thing is not possible, .net standard is only for class libraries. By starting the debug job, the compiler builds a .dll file and the IDE automatically runs dotnet \path\to\output.dll which results in you seeing a console application but not being able to use debugging features.
So changing the project framework from <TargetFramework>netstandard2.0</TargetFramework> to <TargetFramework>.net6.0</TargetFramework> should (or other versions) in your .csproj file should solve the problem.

Sangfroid answered 22/6, 2023 at 16:22 Comment(0)
M
0

100 % This will help and issue solved. Check the Port number in the local host url in your machine. Sometime incorrect port number shall picked and pick the correct one.

Check your URL : http://localhost:portnumber/ Example : http://localhost:12345/

Mephitis answered 20/2 at 10:3 Comment(0)
H
0

Our project is setup to run through Local IIS not IISExpress. So, I have to make sure "Locall IIS" is selected in Web settings of the project's properties. Then do the build. <compilation debug="true"> in web.config file is also important.

Hearthside answered 27/5 at 9:45 Comment(0)
C
-1

In Visual Studio 2010

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

Now Try to rebuild project and try debug

All the best

Condone answered 18/3, 2013 at 2:31 Comment(0)
L
-2

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/

Lilias answered 23/9, 2019 at 7:26 Comment(1)
Would you please explain: what is it addon exactly and what it does.Insertion

© 2022 - 2024 — McMap. All rights reserved.