Breakpoint Failed to Bind - Visual Studio 2015
Asked Answered
M

24

181

I just upgraded from Visual Studio 2013 to 2015 and now I am having trouble with breakpoints.

It's a hit or a miss where break points will actually work and if I set one while debugging I get the error:

The breakpoint failed to bind.

Any help would be appreciated. I am about ready to give up on 2015 and go back.

Merritt answered 30/7, 2015 at 19:59 Comment(0)
H
266

I had the same problem but a different solution. Please note I updated to VS 2015 Update 1 and the problem is still there.

In previous edition of VS starting debug automatically triggered a build in debug mode. But with VS2015 it does not.

So if your last build was in release mode, and you try debugging, breakpoint won't work.

You have to manually build in debug mode first, then start debugging.

Hydrotherapy answered 11/12, 2015 at 10:39 Comment(5)
Isn't this a wierd behaviour? Can it be considered as a bug?Sidney
Installing the Update for Microsoft Visual Studio 2015 Update 3 (KB3165756) fixed the debugging issue for me where previously I was getting "The breakpoint failed to bind ." error in the C# ViewsRooke
This was actually good :) I forgot the release build active and was experiencing very weird debugging session until reading this I remember to activate debug back and everything is "normal".Diarthrosis
I had a weird experience. I had to set the build to "Release", build, then "Debug" and build again.Schlemiel
@TolgaEvcimen Given that after more than 2 years, as of VS 15.5.6, the behavior is still the same, I would say MS doesn't consider it a bug. Personally I would find it more logical to revert to the old behavior of automatically trigger a debug build. Or at least give a warning.Hydrotherapy
L
92

I had the same problem.

I solved it disabling "Optimize code" option in project properties Build tab.

Ligule answered 3/11, 2015 at 8:48 Comment(5)
The issue still ended up coming back on one of my projects. Anyway, Update 1 is out now so hopefully that cleans everything up visualstudio.com/en-us/news/vs2015-update1-vs.aspxMerritt
Isn't that the whole point of a Debug build? I would advise against a Release build with "Optimize code" turned off.Breadstuff
When I looked at the Config Manager, I switched to Debug for the solution, and found some projects were incorrectly set to Release. This means selecting Debug in the drop down would cause those projects to use their Release configuration, meaning optimized.Autointoxication
Still an issue in VS 2019Renege
The "Optimize code" checkbox has independent values in each build configuration, so you can uncheck it in Debug and leave it checked in Release.Tenebrous
S
49

This may seem trivial, but after a lot of headscratching with the same issues as you mention, I found out that my build was set to "release" instead of "debug" when I tried debugging.. re-building the solution for "debug" fixed it, and I could set breakpoints as normal

Schizophrenia answered 13/8, 2015 at 12:12 Comment(3)
That allowed me to set the break points but doesnt last forever. I also still have issues with debugging still skipping random lines of code stillMerritt
This problem persists despite all the one-off temporary reports of success for wildly different solutions. However, this particular "fix" needs to be put along side "is your computer plugged in". It's really not a solution. Yes you do need power and yes you cannot set breakpoints in a release build -- geez.Fictional
@Kenneth Møller As you mention, it may seen trivial but solved my problem too.Hackberry
N
39

I had a similar issue with breakpoints failing to bind, as well as certain local variables not evaluating in the Locals window. What finally fixed it was enabling the "Suppress JIT optimization on module load (Managed only)" option in the Options->Debug->General tab. Once I set that it was able to bind without issue.

Nolan answered 25/8, 2015 at 20:38 Comment(7)
I gave it a shot but still wasnt hitting breakpoints in a my api controllers.Merritt
There is a good explanation on debugging with optimized code hereCompander
Um, no, this is not a solution. What we're getting is people randomly tweaking switching that have no bearing on the issue, that seems to disappear on its ownFictional
Finally. This also allowed me to step through code that was previously being jumped over.Fortuna
This solved it for me in VS 2019, thank you so much!Wesleywesleyan
I had a completely weird behavior with VS2017 and a vb.net project. Lost a full day by trying various "solutions". To enable this option was the solution!Gratulate
For anybody who encountered this problem in between two lines, this solved the problem for me in vs.net 2019. As in, I can place a breakpoint in line 100 and 102 but line 101 gives me the error in this question. Problem solved, thank you.Isom
M
16

I had this problem. I ran a performance profiling session which modified the Web.config file with settings for the performance monitor:

<appSettings>
   <add key="Microsoft.VisualStudio.Enterprise.AspNetHelper.VsInstrLocation" value="C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Team Tools\Performance Tools\vsinstr.exe"/>
</appSettings>


<compilation debug="true" targetFramework="4.5" 
      assemblyPostProcessorType="Microsoft.VisualStudio.Enterprise.Common.AspPerformanceInstrumenter, Microsoft.VisualStudio.Enterprise.AspNetHelper, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
   ...
</compilation>


<runtime>
   <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
         <assemblyIdentity name="Microsoft.VisualStudio.Enterprise.AspNetHelper" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
         <codeBase version="16.0.0.0" href="file:///D:/Program%20Files%20(x86)/Microsoft%20Visual%20Studio/Shared/Common/VSPerfCollectionTools/vs2019/Microsoft.VisualStudio.Enterprise.AspNetHelper.DLL"/>
      </dependentAssembly>
      <dependentAssembly>
         <assemblyIdentity name="VsWebSite.Interop" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
         <codeBase version="8.0.0.0" href="file:///D:/Program%20Files%20(x86)/Microsoft%20Visual%20Studio/Shared/Common/VSPerfCollectionTools/vs2019/VsWebSite.Interop.DLL"/>
      </dependentAssembly>
   </assemblyBinding>
</runtime>

This broke my ability to stop at breakpoints. When I reverted back to the original Web.config (removed the Performance Profiler settings), the breakpoints started working again.

Mathre answered 7/8, 2015 at 20:3 Comment(3)
This was the solution for me after profiling in VS 2017. Many thanks.Pullover
Seems like there are many causes for breakpoints failing to bind, but this is the one we saw.Rigidify
This was it for me. I removed this AppSetting: <add key="Microsoft.VisualStudio.Enterprise.AspNetHelper.VsInstrLocation" value="C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Team Tools\Performance Tools\vsinstr.exe"/>Ungual
L
8

Change Release mode to Debug, In my case, this fixed my problem.

enter image description here

Loach answered 13/12, 2018 at 9:36 Comment(0)
W
5

I had the same issue yesterday. I used the "Clean Solution" feature and it helped.

Whangee answered 26/11, 2015 at 7:59 Comment(1)
It's almost like comedy central. I'm waiting for "I waved a rubber chicken over the machine and that worked". We've got a half dozen developers who've experienced this issue and not one of these ad hoc magical, explanation-free solutions works.Fictional
S
5

the solution is to disable the design optimization.

Project Properties> Build> Advanced Compile Options> Enable Optimizations

Symphonist answered 4/4, 2016 at 13:58 Comment(0)
B
4

I run performance on my solution and that added this to my web.config

<compilation debug="true" targetFramework="4.5" assemblyPostProcessorType="Microsoft.VisualStudio.Enterprise.Common.AspPerformanceInstrumenter, Microsoft.VisualStudio.Enterprise.AspNetHelper, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/> 

the assemblyPostProcessorType is the problem, I deleted it and that solved my problem

Brookhouse answered 9/12, 2015 at 15:30 Comment(0)
M
4

In case you are publishing your web-application check that Configuration is set to Debug(by default in debug configuration is set such that code not is optimized and symbol table is fully created).enter image description here

Marva answered 10/2, 2020 at 13:8 Comment(0)
M
2

STEP 1, Rule out the obvious:

  • Compile in Debug mode.
  • Try to Clean Solution before setting the breakpoint.
  • Go to the Debug folder, and delete [Your application].pdb file.
  • Then do a Build or Rebuild your application.
  • Go to the Debug folder and confirm you have a brand new [Your application].pdb file.
  • Then try to set your break point.

STEP 2 For C++ projects:

Check the following project properties:

  • C++/General/Debug Information Format: Program Database.
  • C++/Optimization: Disabled.
  • C++/Code generation/Runtime library: Multi-threaded Debug.
  • Linker/Debugging/Generate Debug Info: Yes.
  • Linker/Debugging/Generate program database: $(TargetDir)$(TargetName).pdb.
  • Linker/Manifest File/Generate Manifest: No.
  • Linker/Manifest File/Allow Isolation: No.
  • Linker/Embedded IDL/Ignore embedded IDL: Yes.
  • Do Step 1 Again

    You can try adding __debugbreak(). This statement needs to go in your source file where you want to break.

STEP 2 For C# projects:

  • In the projects properties Build/General/Optimize code should be disabled.
  • In the IDE settings Debug/Options and Settings/Debugging/General Suppress JIT optimization on module load (Managed only): Enabled
  • Do Step 1 Again

Try opening your solution on another machines. If you can bind a breakpoint on a different machine this can mean that there is an issue with either your VS or your OS.

STEP 3, Make sure your VS is up-to-date:

There have been reports of issues like this in the VS2013 RTM as well as VS2015 Update 1 and Update2.

In VS go to Tools/Extensions & Updates/Updates/Product Updates and see what version you are running. If an update is needed it will appear there.

STEP 4, Make sure your OS is up-to-date:

Lastly, if your running a Win 10 OS, there was a reported bug regarding this issue which existed in build 14251. This was resolved in build 14257 (and above).

Midpoint answered 25/7, 2017 at 8:8 Comment(0)
D
1

I didn't change the 'optimize' setting, but based on other answers here, I

  1. Set Solution Explorer to Show All Files for the project
  2. Deleted the hidden bin and debug folders
  3. Performed a 'Clean' on the project
  4. Performed 'Rebuild' on the project

So far this has fixed it for me. Seems like updating to VS2015 Update 2 has borked a few things on my system.

Dominik answered 27/4, 2016 at 23:20 Comment(0)
K
1

I know this is an old post but in case all the other tricks above don't work for you make sure the image you are trying to debug is current. For some reason after publishing and transferring a .NET Core project to my Raspberry Pi 'unzip' on the RPi was not copying and overwriting some DLLs in the working directory. When I attached the debugger thinking everything was OK some breakpoints were getting hit, others were not and some others were giving me the "can't bind" error. Once I resolved the unzip issue all my breakpoints and symbols came back. I hope this helps.

Keelung answered 29/4, 2020 at 19:30 Comment(0)
C
0

I encountered the binding breakpoint errors today. And I've solved my problem doing belows.

If your all debug configurations aren't correct you can't fix the problem doing belows.

  1. Clean Project
  2. If the output path is different from bin folder, replace it to the bin folder(this is the most important rule)
  3. Rebuild

Maybe this solution helps someone.

Calvinna answered 7/1, 2016 at 2:28 Comment(0)
K
0

VS breakpoints cannot bind on async methods.

I had an App Dynamics agent installed that caused this. Remove that and you are good to go.

Kongo answered 18/6, 2016 at 10:17 Comment(0)
R
0

The new Update for Microsoft Visual Studio 2015 Update 3 (KB3165756) has fixed the breakpoint issue for me where I'm trying to inspect the local variables in C# code embedded in cshtml files in ASP.NET Core applications.

Rooke answered 1/8, 2016 at 11:15 Comment(0)
F
0

I just ran into a similar problem and none of the answers here hit on the issue I was facing. Unlike in the question, though, I never receive any message saying there was a failure to bind. The breakpoint just never hits. Hopefully this is helpful to someone in the future banging their head on the wall with WCF.

TL/DR:
In the SOAP message there was a record with bad data caused the breakpoint not to get hit.

Full Story:

I have a WCF service based on WSDL from another team. Not my definition, no control over it... I receive messages from this other team through this service. In my case I receive messages, can log the message to the message log table in the database (which happens prior to my service method getting called), the service method is seemingly called (maybe it isn't), and the server responds with a 202 Accepted. Communication is working, except no data gets saved to the database during the method call.

Since the service returns a success response I ruled out http and transport related issues.

So I fired up VS2015 to debug the service. The message in question is large but well within the limits of what I would expect. I put a breakpoint on the first line of the service method and sent the large message through, but the breakpoint never hit. I tried a smaller message that I knew worked on the very same run instance and the breakpoint was hit just fine. So everything in the configuration seemed fine. I thought maybe there was something in the message size.

I tried everything I could find - making sure I was in a debug config, clean and rebuild, manually attaching the debugger to the w3wp process (which VS already was), using Debugger.Break() instead of a breakpoint, setting multiple startup projects, unloading my test project so that the service project was the only one, updating .NET, restarting VS2015, rebooting, switching from Local IIS to IIS Express and back, recreating the service with the guaranteed latest WSDL. Nothing mattered. The breakpoint was never hit.

I ended up having to weed out records in the large message one by one until I found one single record that had bad data. In my case it was one record that had no value for 2 DateTime fields. When I created a message that had just this one record in it and sent it, the breakpoint did not get hit. When I provided values for those 2 DateTime fields and sent the same (fixed) message in the breakpoint fired as expected.

I had every single CLR exception enabled, nothing fired other than missing .pbd files, which I didn't care about. WCF happily sent the request with a bad record through. I'm not saying that WCF shouldn't have sent it through based on the contracts, just that the bad record caused the breakpoint not to be hit.

Fineman answered 11/8, 2017 at 16:58 Comment(0)
R
0

I had to modify the web.config file to enable debugging. Change this:

<compilation debug="true" targetFramework="4.5.2" assemblyPostProcessorType="Microsoft.VisualStudio.Enterprise.Common.AspPerformanceInstrumenter, Microsoft.VisualStudio.Enterprise.AspNetHelper, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>

to:

<compilation debug="true"/>
Recessional answered 26/9, 2017 at 16:5 Comment(0)
R
0

If the other suggested solutions don't work then also verify that your antivirus software is not blocking the debugger (check Windows event logs, etc.). I encountered the same breakpoint error for C/C++ apps in Visual Studio 2022, including a simple test app that had no changes from the project template. Changing project settings and rebuilding didn't help but eventually I noticed errors in the Windows event log that pointed me to the AV software blocking access to the process.

Reproof answered 4/3, 2024 at 17:55 Comment(0)
F
-1

I had the same problem, but hadnt realised that "Debug" had changed to "Release" on the debug tool bar(usually directly under the menu). So I set it to "Debug" it worked.

Falmouth answered 30/5, 2016 at 7:28 Comment(0)
U
-1

I looked over the previous answers and @Will's answear fixed the main issue i was having, the other being able to edit and continue but taking an closer look at the AssemblyInfo.cs file i found out some debugging features where disabled.

Then i ended up removing old debug attributes and adding the following that i took from another project

#if DEBUG
[assembly: System.Diagnostics.Debuggable(System.Diagnostics.DebuggableAttribute.DebuggingModes.DisableOptimizations | System.Diagnostics.DebuggableAttribute.DebuggingModes.EnableEditAndContinue | System.Diagnostics.DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | System.Diagnostics.DebuggableAttribute.DebuggingModes.Default)]
#endif

Yet i feel like this is not the best way of doing it.

Uncle answered 1/8, 2016 at 9:40 Comment(0)
S
-1

I tried everything suggested here. Eventually, I set the "Specific Page" in Project Properties -> Web to my local start URL, page and query parameter. Did a clean and rebuild in debug mode and it hit my breakpoint.

Scrubland answered 23/10, 2018 at 15:41 Comment(0)
M
-1

While this is a much later build (VS2017) I had this issue with C# projects. Tried cleaning, rebuilding, restarting visual studio, etc.

What fixed it was closing Visual Studio and deleting the .vs folder, which is a hidden folder located in the solution directory. Deleting the .vs folder should not cause you any problems, although you will need to reset your startup project.

Mischa answered 26/10, 2018 at 19:45 Comment(0)
P
-1

In my case, there was a new web.config file created after I use Profiler. Restoring web.config to the previous version, resolved this issue. It was a VS2015 C# web application.

Psalterium answered 15/3, 2019 at 15:37 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.