Breakpoint Failed to Bind - Visual Studio 2015 - c#

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.

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.

I had the same problem.
I solved it disabling "Optimize code" option in project properties Build tab.

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

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.

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.

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

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

the solution is to disable the design optimization.
Project Properties> Build> Advanced Compile Options> Enable Optimizations

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

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

I didn't change the 'optimize' setting, but based on other answers here, I
Set Solution Explorer to Show All Files for the project
Deleted the hidden bin and debug folders
Performed a 'Clean' on the project
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.

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

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.

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.
Clean Project
If the output path is different from bin folder, replace it to the bin folder(this is the most important rule)
Rebuild
Maybe this solution helps someone.

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.

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.

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.

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.

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

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!

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.

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.

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.

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.

Related

Breakpoints are not hit. I get "breakpoint will not be hit, the code source is different" message

Working on an old ASP.Net project using VB. I am using VS2012.
The debugger does not handle my breakpoints for a specific class (no prob with other classes so far).
When I run the app without having changed the file, its breakpoints are correctly hit. If I change anything into this file (even adding a \n character), the next time I run the app, its breakpoints are not hit anymore and I can read under the breakpoint the usual warning saying that "breakpoints will not be hit because the source code is different".
How can I have the debugger to accept my changes into this file? Why is it only causing trouble with this specific file?
I tried to remove my ASP temporary files as suggested in other similar posts. Did not help.
Rebuilding does not help either.
Thx in advance
Solution 1: Right click on the break point->Location->Allow the source code to be different from the original version(Tick the check box).
Solution 2: If the above solution doesn't work goto Debug->Attach to process, then attach the port/ service in which your current web project runs.
Hope this helps.
I would make sure that you currently have the Configuration Manager set to "Build" the ASP.NET project that you're making changes in. This is found under Build -> Configuration Manager.
Then rebuild the solution/project.

The Breakpoint will not currently be hit. No symbols where loaded for this document

Windows 8, VS2013 IIS8,5
I'm trying to connect to a local WEB API by connecting to processes w3pv.exe (Managed (v4.0.30319), 19). The website front end and back end is both running fine on my local IIS. Right after publishing my x86 web API to the local IIS i try to connect to the process, where the break point states "The Breakpoints will not currently be hit. No symbols where loaded for this document". My colleague' can without any problems debug from his local computer.
So far I have.
Reinstalled VS2013.
Checked All Debug Properties
-Project -> build: Define DEBUG constant check / Define TRACE constant check.
Generate serialization assembly = Auto. Advanced build settings -> Debug info = full
Enable Just My Code: Check, Use Managed Compatibility Mode: Check
Enable Edit and Continue : Check
Made sure all Debug mode is set and all project Configured to Active solution platform x86, marked Debug and Build.
Deleted all bin and obj folders, as well as pdb folder in C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files
Reset IIS.
Set Select Code Type to Automatically determine the type of code to debug
Checked in IIS that .Net compilation -> Debug and Enable Prefetch is set to true.
And I still get the same error message. Anyone found anything in addition to this?
I have encountered similar problems many times while training new employees in our very complicated devenv, so here is our internal step by step instruction:
Don't panic
Make sure you attached the debugger to the correct process - you debug the plugin by launching VMS which is external app that has separate config file where the plugin path is stored, so when you change just your configuration Debug/Release it doesn't work.
Make sure you have symbols generated for the assembly Project properties->Build->Advanced->Output section
Make sure the build path hasn't changed. You may have accidentally changed the path and you may only think that the assembly you are trying to debug is the correct one.
Investigating the information you provided this is only help I can think of. My guess is the files you publish are not the files you're debugging locally.
RESOLVED (embarrassed)
A few day's ago, I downloaded the front-end code for the website from the VPN (GIT). I forgot to update the code-behind reference in the App.js file in the front end root. This, of course, referred to the API on the cloud, and not my local API.
This took me way to long to find out. But, at the same time, it's not a solution I've seen so far on the web.
Thanks for all your help.

Visual Studio 2015 RTM - Debugging not working

I have installed VS 2015 RTM (nothing else) and I'm unable to debug any solution, not matter if it's an existing one or a brand new one (created with VS 2015 and compiled against .Net Framework 4.6), it only opens a new tab in VS which is called Break Mode with the following text:
The application is in break mode
Your app has entered a break state, but no code is executing that is supported by the selected debug engine (for e.g. only native runtime code is executing).
And if I check the Debug --> Module Window:
VS2015Test.vshost.exe no symbols loaded (even if I click load symbol it does not work)
VS2015Test.exe symbols loaded
And it also doesn't show the output on the console(it's a console application that just has the following lines of code:
class Program
{
static void Main(string[] args)
{
Console.WriteLine("TEST");
Console.ReadKey();
}
}
I tried to reinstall VS 2015, restarted the computer, deleted all files in %temp%/AppData/Microsoft/Visual Studio/14, started VS in Admin Mode but nothing seems to work.
One thing which makes debugging working is this option:
Tools --> Options --> Debugging --> Use Managed Compability Mode
^^But that can't be the solution to use an old/legacy mode.
BTW: Debugging in VS 2013 is working fine.
Any help would be appreciated.
In my case this solution is useful:
Solution: Disable the "Just My Code" option in the Debugging/General settings.
Reference: c-sharpcorner
I was having this same problem with VS2015. I reset the settings, as suggested but still had trouble.
What I had to do to fix it was check "Use Managed Compatibility Mode" and "Use Native Compatibility Mode". Not sure which of those 2 is necessary but checking both and I no longer get the Break Mode issue.
I had a very similar issue recently, related to debugging settings.
Firstly have you tried resetting all your settings? I think it may be related to that as you say it is project independent and you've deleted all application data.
Tools-> Import and Export Settings Wizard -> Reset all settings
Don't worry, it gives you the option to save current settings.
Secondly if this fails, I would suggest looking at the event log.
Entering break mode would suggest that the DE (debug engine) is sending a synchronised stop event to visual studio like IDebugExceptionEvent2. I would take a look at the event log for exceptions like failures in loading referenced assemblies (like .NET runtimes, etc) or environment access restrictions.
Something is telling the debugger to stop your running application, its just a case of finding it.
Thought I would post this in case it helps anyone. I installed a clean Win 10 and Visual Studio 2015, tried to debug an existing solution and had problems. Followed some advice listed here and other places but none worked.
How I got the debugging to work as normal was to change the Solution Configuration just below the menus. I had it set previously to Release mode, changed this to Debug and then cleaned/recompiled and hey presto, debugging started working as normal. See the image for info:
My solution suddenly stopped to work in debug.
I received a message during debug.
[Window Title]
Microsoft Visual Studio
[Main Instruction]
You are debugging a Release build of NettoProWin.exe. Using Just My Code with Release builds using compiler optimizations results in a degraded debugging experience (e.g. breakpoints will not be hit).
[Stop Debugging] [Disable Just My Code and Continue] [Continue Debugging] [Continue Debugging (Don't Ask Again)]
I chose to continue to debug, but it still did not work.
The solution was simple. It is necessary in the project properties -> in the build section -> remote the check "Optimiz code"
Check the "Code Type" before attaching to a Process. For example, I had to switch from CoreCLR to v4.*
In my case,
I have changed Platform from x86 to x64 in Debug Configuration Manager. It worked for me.
I disabled avast file system shield and then all worked normal again.
avast-setting wheel= active protections- top button off.
Same is required to publish projects. A real nightmare
I had a problem similar to this when trying to use Debugger.Launch to debug a web application: the JIT Debugger Selection window never appeared. I knew it wasn't a problem with VS debugging mechanism itself because it fired just fine with a console app.
Eventually a colleague mentioned a "global debugger registry setting" which set off a light bulb.
I was using Microsoft's DebugDiag some months ago to troubleshoot IIS crashing, and I had a rule registered to capture IIS crash dumps, which obviously (in retrospect) registered the Debug Diagnostic Service as the debugger for w3wp (IIS worker process).
Removing the rule in DebugDiag, or stopping the Debug Diagnostic Service ("C:\Program Files\DebugDiag\DbgSvc.exe") re-enabled Visual Studio's JIT debugging.
Hope this helps someone.
Uhg. I hit the bottom of this page so I started ripping apart my project. I found a solution for my particular problem.
My Issue: I couldn't hit the break-point inside a threaded process. Nothing fancy, I'm just starting a new thread in a console app and the debugger wasn't stopping on the break points. I noticed the thread was being created but it was getting hung up in .Net Framework external calls and specifically the ThreadStart_Context. That explains why my breakpoints never got hit because the .Net Framework is getting hung up something.
The Problem: I found that I could solve this by changing my startup code. For whatever reason, I had a program.cs file that contained Main() and was inside the Program class as you would expect for a console app. Inside Main(), I was instantiating another class via this code;
new SecondClass();
This normally works fine and I have a bunch of other projects with Threaded calls where it works fine (well, I haven't debugged them for some time so perhaps a service pack came along and is causing this regression).
The Solution: Move Main() into my SecondClass and instead of invoking the SecondClass constructor via 'new SecondClass()', update the SecondClass constructor to be a standard static method and then call it from Main. After making those changes, I am able to debug the thread once again.
Hope this helps.
After installtion of vs 2017,while debugging the solution,there was an error like "Webkit has stopped functioning correctly; Visual Studio will not be able to debug your app any further.",this makes unable to proceed the debugging.To resolve this issue,Go to Tools->Options->Debugging->General then disable the javascript debugging for asp.net
I have had similar issues on my svc application run on visual studio 2015, the solution was to change solution platform from "Any CPU" to "x86", if you cannot see the x86 option then click on "Configuration Manager" and go to your target project and change the platform, you'll need to select the dropdown and click "New", on the pop up, click the drop down list under "new platform" and select x86, save your changes and rebuild(See attached)
Stop debugging.
Edit csproj.user file
Find section wrote below:
<SilverlightDebugging>True</SilverlightDebugging>
Change Value to "False"
Unload and reload your project in Visual Studio.
Sometimes it needed to close Visual Studio.
A friend had the same problem, he couln't debug in VS2015 but it was ok in VS2013. (our project is in .Net v4.0)
We have found that it was the "Code Type" option in Debug / Attach to Process that was set to "Managed (v3.5, v3.0, v2.0)" instead of "Managed (v4.5, v4.0)"
I had this issue, and none of the (myriad of) posts on here helped. Most people point towards settings, or options, turning on Debug mode, etc. All of this I had in place already (I knew it wasn't that as this was working fine yesterday).
For me it turned out to be a referencing issue, a combination of DLLs that were included were to blame. I can't say exactly what the issue was, but I have a couple of classes that extended base classes from another project, an implemented interface that itself extends from another interface, etc.
The acid test was to create a new class (in my case, a Unit Test) within the same project as the one failing to Debug, then create an empty method and set a breakpoint on it. This worked, which further validated the fact my settings/options/etc were good. I then copied in the body of the method that failed to Debug, and sure enough the new method starts failing too.
In the end I removed all references, and commented out all the lines in my method. Adding them back in one by one, checking Debug at each step, until I found the culprit. I obviously had a rogue reference in there somewhere...
We had this issue, after trying all other options such as deleting .vs folder, Renaming IISExpress folder name, Updating various setting on properties etc it did not work. What worked though, was uninstalling IISExpress 10.0, and Reinstalling it along with turning all IIS related features on from Windows Features. Hope this helps someone.
I changed my Platform Target from "Any CPU" to "x64".
Setting available at : Project Properties -> Build -> General: "Platform Target"
I use VS 2015.
I found I had to go to the project settings -> web, and tick the Enable Edit and Continue checkbox. I cannot say why it was unchecked to begin with, but this solved it for me.
from Solution Explorer -> Web -> Properties
select Build tab -> Configuration combobox:
Just change your Configuration from "Release" to "Active (Debug)"
In my case it was due to the project Target platforms were different.
Consider : ProjectA (Entry) --> ProjectB
ProjectA's platform in properties was set to x64.
And ProjectB's platform was 'AnyCPU'.
So after setting ProjectB's target platform to x64 this issue got fixed.
Note: It's just that Target Platform has to be in sync be it x64 or
'Any CPU'
In my case, I found a hint in the output window that the exception that stopped the debugger was a ContextSwitchDeadlock Exception, which is checked by default in the Exception Settings. This Exception typically occurs after 60 seconds in Console applications. I just unchecked the exception and everything worked fine.
I had this same issue. In my case, the dll I was trying to debug was installed in the GAC. If your debugging breakpoint hits when you aren't referencing any object in the target assembly, but doesn't when you reference the assembly, this may be the case for you.
I had this problem after deinstallation of RemObjects Elements 8.3 Trial version. Reinstall Elements 8.3 is a quick bugfix.
I got in this issue as well. I'm using VS 2015 (Update 3) on Windows 10 and I was trying to debug a Windows Forms Application. None of the suggestion worked for me. In my case I had to disable IntelliTrace:
Tools > Options > IntelliTrace
I dont know the reason why, but it worked. I found out the root of the problem when I opened the Resource Monitor (from Windows Task Manager) and I realized that IntelliTrace process was reading a tons of data. I suspect this was causing locks in vshost process, because this one was consuming 100% of a cpu core.
I hade the same problem. After trying the other solutions here without luck, I had to repair the installation through the installer.
Control Panel > Programs > Programs and Features
Then scroll down to Microsoft Visual Studio, right click it, then "Change". Then at the bottom of the window, click Repair. The repair process will take a decent amount of time, and at the end you will have to restart your computer.
This fixed the problem to me, and I hopes it will help you.

How can I debug "Object reference not set to an instance of an object" in VS2013?

I have a c# Azure project that is just a web api, and wanted to remove some of the non-API default components (welcome page, help, etc). After doing so, when launching the application, I get an error message "Object reference not set to an instance of an object." I've seen this before when doing things in Azure, and somehow got around them each time. My question really is: how can I debug this error on my own? This error description is woefully lacking in detail (there's no call stack or anything, as if the app hasn't yet launched, and the dialog is modal so I can't click on anything within VS)
Extra notes:
it's an ASP .NET project.
it works once I publish to Azure.
after copying the project entirely and rebuilding, it seemed to work. then when mucking with NuGet dependencies, we're back to it not working (i've tried deleting my packages folder and having NuGet recreate - no luck; no idea if related to NuGet at all)
I re-copied the project, so just 'MySolutionFolder' -> 'MySolutionFolder - Copy', reopened with same version of VS, runs fine. This is an amazingly sloppy solution obviously, so looking for something better.
As described in a comment, the issue presumably dealt with access rights to various files, most likely NuGet related but possibly Azure as well, which explains why copying to a new solution directory 'fixed' the issue. I would love to see better error info, such as "Error: Visual Studio couldn't write to 'packages.config'", so I know actually where to fix this sort of issue. As it stands now, it's like a compilation error that says "Syntax error in code. Somewhere. Good luck finding it".
Unfortunately, I never did discover a way to debug issues of this sort in a more general way. I eventually worked around the problem, and then saw it pop up again; following advice someone else tried on another forum, I deleted my packages folder, and had NuGet recreate it, which for whatever reason corrected the issue.
Another time, a solution from this question worked (remove and re-add all roles); sometimes this seemed to require an Azure SDK reinstall and computer restart as well.
EDIT
Finally, the best solution I could find was here: delete SUO files and restart VS.
Hopefully this solution will help someone with a similar problem in the future!
tick Debug > Exceptions > Common Language Runtime Exceptions > System > NullReferenceException and run your app
You can enable Intellitrace and remote debug your azure services:
http://blogs.msdn.com/b/webdev/archive/2013/11/05/remote-debugging-a-window-azure-web-site-with-visual-studio-2013.aspx
I've seen similar symptoms when something goes wrong very early in the asp.net app start-up cycle (before the debugger has attached).
One workaround I have used before:
Make sure you are debugging with a local IIS instance and not IIS Express (right click project properties -> Web -> Servers dropdown -> Local IIS
Hit F5 and get your error dialog. (Just to make sure the IIS process has started). Close the error dialog.
Debug -> Attach to Process -> attach to w3wp.exe (iis process). If it's not there make sure 'show processes from all users/sessions' are both checked.
Force a restart of your app by changing the web.config file.
The restart will now occur with the debugger attached to the process from the very start. If that doesn't give any more useful info, then look at turning off 'Just My Code' debugging exception/breakpoint handling and repeating.
For Visual Studio 2019, click on menu "Debug > Windows > Exception Settings".
Under Common Language Runtime Exceptions, tick on System.NullReferenceException. Debugger will break at the point where this exception is caught.
You can setup a local Azure emulator, this is how I've always debugged my cloud apps.
http://msdn.microsoft.com/en-us/library/windowsazure/hh403990.aspx
And maybe do some reading!
http://msdn.microsoft.com/en-us/library/windowsazure/ff683670.aspx
http://msdn.microsoft.com/en-us/library/windowsazure/hh694035.aspx
Inside global.asax:
protected void Application_Error(object sender, EventArgs e)
{
var error = Server.GetLastError();
string message = error.Message;
string callStack = error.StackTrace();
//Write message and callStack to file
...
}
I don't think debugging will help in this case.
However, unloading/reloading your Azure project by right-clicking on it might fix. I'd tried a LOT of things before discovering this one.
As mentioned here.
I also had the "Object reference not set" issue starting Compute Emulator. I found running VS as administrator resolved this.
Changing project target to 4.6.1. seems to have worked for me.
You can debug through logs. Like you can check through diagnostic logs. Enable them through code. There are some configuration for it. I also faced this type of issue and that was very difficult for me to trace. So i enabled the diagnostic logs and write on logs on my custom check point.

Visual Studio Breakpoint Warning

When debugging my code, I often throw breakpoints in to check the values of local variables to make sure everything is on the right track.
Lately, when I make changes to my code and recompile, all my breakpoints turn into the outline of a circle (instead of a full red circle) and it gives me an error that reads;
The breakpoint will not currently be hit. No executable code is
associated with this line. Possible causes include: conditional
compilation or complier optimizations.
What's strange about this issue is that I can simply remove and add the breakpoint and everything will work completely fine.
I am not using any type of conditional compilation or complier optimizations. Does anyone know what this means or how to fix this? It gets quite annoying replacing 10-12 breakpoints each time I compile.
This can happen for a few reasons
The code the debugger is using is different from the code that the application is running
The pdb file that the debugger is using is different from the code that the application is running
The code the application is running has been optimized and debug information has been stripped out.
The code in which you have breakpoints on hasn't been loaded into the process yet (assuming the things above are not the culprits)
If you are attaching the debugger, pay attention to what .net framework it's attaching to (i've had issues with it using .net 4 when code was all .net 2.0)
The assembly you have is also in the GAC. This might happen if say you installed your program so you could debug it, but the installer put the dll in the GAC.
Remove the reference and re-add it (thanks to forsvarir). Typically this occurs when the project that is referenced is not in the solution, and VS will copy the dll from the bin directory of another project. You will know this was the issue when you try to re-add the reference, and can't find the project :)
It's pretty tough to figure out what's going on here, but i would suggest using the fusion log viewer to see what is being loaded and where it's being loaded from and then you can look at the dll and see if it's old code, etc.
Check the project settings
Make sure you don't check the code optimize option, and make sure debug symbols are checked.
Notice that when you change the configuration other settings might change as well and you might not see. Make sure the values are correct for the configuration you are attempting to compile.
Delete the output files
Physically delete all generated DLLs, PDBs and EXEs. Then compile again to generate the files. Sometimes Visual Studio can "get lost" and "forget" to overwrite the output files when you build your solution.
Restart your computer
It usually solves 99% of problems. I already had some issues with Visual Studio and restarting it or the computer solved the problem.
I know this is an old post but still timely enough as I was looking for any other reason I might be getting this problem.
That being said you also might want to check the "Temporary ASP.NET Files" in your c:\Windows\Microsoft.NET\[Frameworks] directories if you are creating a web application as these files are often the cause in my experience.
The use of the precompiler directive #line appears to affect the breakpoints behavior as well, as I've just discovered.
Adding this response to the old thread in case someone like me is tracking down this mystery in an older ASP.Net application. I had one Webform code-behind which did not respond to breakpoints with the "...no executable code..." debugger warning. It was doing my head in as all of the other pages were working fine. I'd done the clean, rebuild, purged the temporary ASP.Net files, no joy.
The culprit with this file was the inclusion of several #ExternalSource directives surrounding some of the member variable declarations. Once those were removed and the project rebuilt, the break point behavior was restored. Those ExternalSource lines were appearing in the generated section of the code-behind. Not sure why they were there.

Categories

Resources