NovaDev
NovaDev

Reputation: 2971

Breakpoints set but not yet bound in Visual Studio

Running Visual Studio Community 2017. Created a WebAPI project, have a controller class in there, with some basic stuff, but when I go to run in debug mode, I get the following error on my breakpoints, and I haven't the foggiest idea why.

The breakpoint will not currently be hit. Breakpoints set but not yet bound.

I've seen a few answers here and there, but they don't help, or they're about Visual Studio Code, which I am definitely not using.

I found this, but it doesn't tell me what to do about my problem. How do I fix this issue?

Upvotes: 66

Views: 102470

Answers (24)

Tech Master
Tech Master

Reputation: 1

It may be due to code optimization option If you already in debug settings and its still not working try the following:

Open Visual Studio (2022) Right click on the Project where the class related to Select properties On the "Optimize Code" section check the Relase and UNCHECK the debug options.

Try now to hit the breakepoing.

Itzik

Upvotes: 0

Elyasaf755
Elyasaf755

Reputation: 3519

For ASP debugging:

  1. Open Chrome/Edge
  2. Go the URL of the startup project
  3. Debug -> Attach to Process -> Search w3wp.exe -> click it and press the "Attach" button

Upvotes: 0

code_disciple
code_disciple

Reputation: 186

Ran into this issue when creating a custom web.config template on an ASP.NET MVC Application. Issue was inside the *.csproj, had to set the following PropertyGroup.

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Your_Custom_Configuration|AnyCPU' ">
        <DebugSymbols>true</DebugSymbols>
        <DebugType>full</DebugType>
        <Optimize>false</Optimize>
        <OutputPath>bin\</OutputPath>
        <DefineConstants>DEBUG;TRACE</DefineConstants>
        <ErrorReport>prompt</ErrorReport>
        <WarningLevel>4</WarningLevel>
</PropertyGroup>

Upvotes: 0

Abdulhakim Zeinu
Abdulhakim Zeinu

Reputation: 3829

Please try following steps to troubleshoot:

1). Build > Clean Solution and then restart Visual Studio and rebuild your project, after that debug again.

2). Please go to your solution folder and delete(or rename) the “obj”, “bin” and the hidden “.vs” folder, restart Visual Studio and then rebuild your solution.

3). Check if you have chosen the “Debug” mode and if you have many other projects in this solution, make sure you have set the “Set as Startup Project” for the corresponding project.

Source

Upvotes: 1

Ajay
Ajay

Reputation: 21

This helped me

1). Build > Clean Solution and then restart Visual Studio and rebuild your project, after that debug again.

https://learn.microsoft.com/en-us/answers/questions/265772/visual-studio-debugging-breakpoint-set-but-yet-bou.html

Upvotes: 2

Justin
Justin

Reputation: 301

On an ASP.NET web project, this message appeared when trying to set a breakpoint on a script that was apparently cached - the browser wasn't loading the updated version of the script (originally embedded in the HTML, then moved to a separate file).

Clearing the cache resolved it.

Upvotes: 0

Alex
Alex

Reputation: 11

If your breakpoint is in a different project and only this one is not reachable, check if "Enable Just My Code" is activated under Tools > Options > Debugging > General.

Upvotes: 1

Avinash Pohane
Avinash Pohane

Reputation: 1

vs might be in release mode. just change it to debug mode

Upvotes: -1

CaptainGenesisX
CaptainGenesisX

Reputation: 405

My team was able to resolve this issue today and I wanted to share the solution because it is unique from everything else I have read online. I hope it helps someone out there.

Here's our situation for some context: We have an ASP.NET solution in Visual Studio that has two projects: one for the API and one for the website. It's got a mix of jQuery, JavaScript, and C# code. We were able to debug JavaScript & jQuery code, but NOT the C# code. That is when we were getting the dreadful "Breakpoints set but not yet bound in Visual Studio" error. To make a long story short, we had to update a web.config file to point to the correct localhost port on my machine instead of the server.

This is what we had to do to get it working:

  1. Open an instance (we will call this "the first instance") of Visual Studio (we will call it VS from now on) with the website project set as the Startup Project.
  2. Open a second instance of Visual Studio with the API project set as the Startup Project. Click the Start button to open the web browser. You may get a server error (I did) but that's okay. Copy the full address in the address bar (for example http://localhost:12345/).
  3. Back to the first instance of VS, we had to edit the web.config file for the website project to point to the address we copied above. This value was in the configuration section under appSettings. There was a key in there that looked like this once we changed it:
    <add key="WebAPI_Address" value="http://localhost:12345/" />
  1. Once this information is saved, we had to Start the API project in the second instance of VS, and then go to the first instance of VS and Start the website project there.

I hope I didn't leave anything out. One thing to note is, the website localhost address is different for us compared to the localhost address when the API project was launched. One of our developers got the same port number for both. To resolve that issue, he had to Start the API project using a different browser, and then he got a unique port number. I don't know why, maybe it depends on the environment.

Upvotes: 0

Rares-Mihai Chelariu
Rares-Mihai Chelariu

Reputation: 129

If any of the top answers fail for you, restart computer, then run again in Debug mode.

Upvotes: 0

D-Shih
D-Shih

Reputation: 46219

If you are using Multiple projects, you need to make sure the step below, let project debug normally

  1. Confirm the project which you want to debug is a default project, otherwise setting it as startup project enter image description here
  2. Confirm your project mode is Debug instead of Releaseenter image description here
  3. Clean your solution or projects and rebuild your projects enter image description here
  4. Restart & Running your Current project.

Upvotes: 13

FarrukhMalik
FarrukhMalik

Reputation: 177

Did everything but the issue was there, got it resolved finally when I cleared the cache of browser and the temporary ASP .Net Files folder in Windows/Microsoft .NET/Framework and Framework64.

Upvotes: 0

Martin
Martin

Reputation: 11

I had exactly the same message even though I tried most of the suggestions here. What worked in the end was to change the "Project Url" under "Properties" of the website project. In my scenario I changed it from http://localhost/productname.web to http://localhost:56260.

Upvotes: 1

Hari
Hari

Reputation: 137

Need to set the Solution Configuration to Debug mode. If it is release mode, the breakpoints will not be hit

enter image description here

Upvotes: -1

Rajeesh R
Rajeesh R

Reputation: 1

"Break point will not be hit" warning will show, when you try to put a break point in "javascript" file while the solution is running .Solution to this is , stop debugging and put break point in the javascript and run the project again

Upvotes: 0

Deekshith Shekar
Deekshith Shekar

Reputation: 9

Select Debug instead of Release...And it might work..

Open this link to see the step

Upvotes: 0

Ruben
Ruben

Reputation: 149

Usually it can happen even if all the configurations in project are OK, so do the following.

Right Click to Solution and under Configuration change Release to Debug

enter image description here

Upvotes: 1

Diego Quiros
Diego Quiros

Reputation: 59

If you have a typo in your Javascript, the breakpoint will not work. I used "<>" instead of "!=" and when I fixed it, the breakpoint worked again.

Upvotes: 0

kall2sollies
kall2sollies

Reputation: 1549

If your Web API project is running in IIS, and / or was launched on a terminal (e.g. if you are using .net Core), and that you are in a case that you need to attach the debugger to an already running process, make sure Visual Studio was run as an administrator, unless it won't be allowed to attach to the process.

Upvotes: 0

Ali Hamza
Ali Hamza

Reputation: 21

It worked for me:

1.Clean the Solution 2.Set Startup Project 3.Restart the Visual Studio

Upvotes: 1

shdr
shdr

Reputation: 966

Clean the solution:

Build -> Clean [solution name]

Upvotes: 4

Towhid
Towhid

Reputation: 2084

Just clear the solution and re-start Visual Studio.

Upvotes: 4

Sandeep Kumar Singh
Sandeep Kumar Singh

Reputation: 529

Change your Project mode from Release to Debug in your Visual Studio.

Debug Mode

Upvotes: 52

k1dev
k1dev

Reputation: 641

Try setting your web project as default Startup Project.

Upvotes: 21

Related Questions