Breakpoint Failed to Bind - Visual Studio 2015

C#Visual StudioVisual Studio-2013Visual Studio-2015Breakpoints

C# Problem Overview


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.

C# Solutions


Solution 1 - C#

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.

Solution 2 - C#

I had the same problem.

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

Solution 3 - C#

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

Solution 4 - C#

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.

Solution 5 - C#

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.

Solution 6 - C#

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

enter image description here

Solution 7 - C#

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

Solution 8 - C#

the solution is to disable the design optimization.

Project Properties> Build> Advanced Compile Options> Enable Optimizations

Solution 9 - C#

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

Solution 10 - C#

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

Solution 11 - C#

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.

Solution 12 - C#

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

Solution 13 - C#

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.

Solution 14 - C#

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.

Solution 15 - C#

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.

Solution 16 - C#

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.

Solution 17 - C#

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.

Solution 18 - C#

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.

Solution 19 - C#

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"/>

Solution 20 - C#

Clean the entire solution before trying any of the other solutions. After trying almost everything else said in earlier answers, and restarting visual studio several times, just cleaning the solution did the trick!

Solution 21 - C#

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.

Solution 22 - C#

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.

Solution 23 - C#

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.

Solution 24 - C#

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSealer_05View Question on Stackoverflow
Solution 1 - C#Max FavilliView Answer on Stackoverflow
Solution 2 - C#Edu_LGView Answer on Stackoverflow
Solution 3 - C#Kenneth MøllerView Answer on Stackoverflow
Solution 4 - C#WillView Answer on Stackoverflow
Solution 5 - C#AllbiteView Answer on Stackoverflow
Solution 6 - C#Irshad Ahmed AkhonzadaView Answer on Stackoverflow
Solution 7 - C#kerneldebuggerView Answer on Stackoverflow
Solution 8 - C#Julio ChiuchiView Answer on Stackoverflow
Solution 9 - C#xszabojView Answer on Stackoverflow
Solution 10 - C#VSBView Answer on Stackoverflow
Solution 11 - C#louisik1View Answer on Stackoverflow
Solution 12 - C#Merav KochaviView Answer on Stackoverflow
Solution 13 - C#Brian CleverView Answer on Stackoverflow
Solution 14 - C#RockOnGomView Answer on Stackoverflow
Solution 15 - C#Jared McCrackenView Answer on Stackoverflow
Solution 16 - C#DaniView Answer on Stackoverflow
Solution 17 - C#hemView Answer on Stackoverflow
Solution 18 - C#squillmanView Answer on Stackoverflow
Solution 19 - C#idunnoView Answer on Stackoverflow
Solution 20 - C#chaosifierView Answer on Stackoverflow
Solution 21 - C#IrishChieftainView Answer on Stackoverflow
Solution 22 - C#ChrisBeamondView Answer on Stackoverflow
Solution 23 - C#eagalView Answer on Stackoverflow
Solution 24 - C#Raldo94View Answer on Stackoverflow