Gaby
Gaby

Reputation: 3033

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.

Upvotes: 30

Views: 151071

Answers (19)

Viraj Madhusanka
Viraj Madhusanka

Reputation: 1

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.

Upvotes: 0

Jeyaganesh T
Jeyaganesh T

Reputation: 1

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/

Upvotes: 0

Bamdad
Bamdad

Reputation: 838

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.

Upvotes: 0

Sanjoy Moitra
Sanjoy Moitra

Reputation: 1

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

Upvotes: 0

yangli.liy
yangli.liy

Reputation: 101

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.

Upvotes: 0

Dr Zeeshan Patoli
Dr Zeeshan Patoli

Reputation: 11

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

Upvotes: 0

Abhishek Bhandari
Abhishek Bhandari

Reputation: 1

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/

Upvotes: -2

Shakeer Hussain
Shakeer Hussain

Reputation: 2526

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

Upvotes: 0

mrosiak
mrosiak

Reputation: 2577

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.

Upvotes: 3

Davide Cannizzo
Davide Cannizzo

Reputation: 3134

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.

Upvotes: 0

Gaby
Gaby

Reputation: 3033

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.

Upvotes: 27

Rahav
Rahav

Reputation: 1855

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.

Upvotes: 0

Arun Prasad E S
Arun Prasad E S

Reputation: 10115

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

Upvotes: 4

Syed
Syed

Reputation: 29

In Visual Studio 2010

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

Now Try to rebuild project and try debug

All the best

Upvotes: -1

bresleveloper
bresleveloper

Reputation: 6070

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

Upvotes: 0

DOK
DOK

Reputation: 32841

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.

Upvotes: 2

Aim Kai
Aim Kai

Reputation: 2909

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>

Upvotes: 2

Gerrie Schenck
Gerrie Schenck

Reputation: 22368

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.

Upvotes: 2

Andrew Hare
Andrew Hare

Reputation: 351516

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

Upvotes: 11

Related Questions