ASP.Net break point set but not firing in visual studio 2019 - asp.net

I've got a old asp.net project that I'm having trouble getting the breakpoints to hit when I open it in Visual Studio 2019.
It just seems to step over the breakpoints.
The project is set to Debug mode, I've also checked the output window and the symbols are being loaded.
If I add in the following line of the code
System.Diagnostics.Debugger.Break();
It will break, but if I remove the above line of code the break point on the next line does not get hit.
Has anyone else experienced behaviour like this and did you manage to solve the problem?

Has anyone else experienced behaviour like this and did you manage to
solve the problem?
Please try these:
1) delete all breakpoints under Debug-->Delete all breakpoints
2) check Managed Compatibility Mode under Tools->Options->Debugging-->General
and check Enable .NET Framework source stepping under Tools->Options->Debugging->General
3) close VS Instance, delete .vs hidden folder,bin,obj folder under the path of your project and then restart your project.
4) Right-click on your project-->Properties-->Build-->choose Optimize Code.
In addition, if these do not work, Running the VS command prompt as admin and then runn devenv /setup.

in my case it was ridiculous, in the emulator the network data was off, turning it on solved the problem

Related

Design/Split hanging in Webform

Until about an hour or so ago, I had no problems with Visual Studio - I could view my webforms, make changes etc. All of a sudden, clicking Design or Split just hangs. I don't get an error, it just sits there. I can close the form, but going back into Design view for any for webform does the same thing.
I created a new blank web project, added a blank Default.aspx page - same issue.
I have tried restarting the computer, creating a new windows user and trying on that account and installing AspNet5.ENU.RC1_Update1_KB3137909 (which was an update that was showing up in Visual Studio).
Nothing is working, anyone know of any tips that might get it working?
EDIT:
If I close the webform and right click it in Solution Explorer and view markup and then click Shift-F7 to get design view, I get the following error:
Class not registered looking for object with clsid {A53914B4-1C62-4D60-8E8D-C7B67B4DFF87}
After googling for a long time and trying lots of different approaches, the only successful approach was running the Visual Studio installer and selecting Repair.
This took the better part of an hour to run, but has corrected the issue.
For what it is worth - the issue: Class not registered looking for object with clsid {A53914B4-1C62-4D60-8E8D-C7B67B4DFF87}
Seems to point to an error in the fpeditax.dll in the Common7\Packages folder
So final solution: Run a Repair from the installer.
Do two things:
1) right click the file you want to edit, and select "Open With" - make a note of which editor is the default, you'll need that later. Now, choose a different editor, and set that as default.
2) If (1) works, it's the editor that is jamming up, and you should do this:
Start visual studio from a command line with this line:
devenv.exe /ResetUserData
you may want to delete the ".vs" folder in your project at the same time.
Now, do the same thing, right click the file, set BACK the default editor you took a note of, and you should be OK. This usually solves most of the issues related to a specific file type not wanting to work

VS 2013 ASP.NET can't modify the code while debugging

I'm working with a ASP.NET 2.0 project that has been upgraded from vs 2005->2010->2013.
In vs 2005 and 2010 I can modify the code while debugging, save the changes, and reload the page with the changes applied.
Now in vs 2013 I can't do this. Can't change the code when I hit a breakpoint. Tried to activate all checkboxs in "Edit & Continue" options, but nothing worked.
It's annoying having to stop debugging and recompile the app to debug again the changes.
How can I solve this?
FINALLY figured it out. Here are my findings.
To Reproduce:
I created 2 vanilla projects:
1) .net 4.0 project with VS2012 (ProjectA)
2) .net 4.5 project with VS2013 (ProjectB).
Then opened ProjectA with VS2013 and I couldn't Edit & Continue (E&C).
Resolution:
In VS2013, go into the project's properties on the "Build" tab and uncheck "Optimize Code".
I still don't know why I could Edit & Continue in VS2012 even with "Optimize Code" checked, but in VS2013, it won't work.
Resources:
Here is the link that aided me in locating the problem:
http://msdn.microsoft.com/query/dev12.query?appId=Dev12IDEF1&l=EN-US&k=k(vs.debug.ENC.SupportedButNotAvaiable);k(TargetFrameworkMoniker-.NETFramework,Version%3Dv4.0);k(DevLang-csharp)&rd=true
Hope this helps!
I know this is a bit old, but I found the answer today - at least one answer. I'm running Visual Studio 2013 Update 1 and in my case, attempting to debug an MVC 5 application. Switch your target platform (in the Build menu) from Any CPU to either x64 for 64-bit or x86 for 32-bit.
I ran into this today while attempting to debug my MVC 5 application. After reading the release notes for Visual Studio 2013, including the fact that they added the ability in, I was puzzled. I checked my properties and saw that Optimize Code was unchecked while Edit & Continue were checked. The only other debugger marked was ASP.NET. On a hunch, I changed from targeting Any CPU to just targeting x64 under the Build menu. After that, I was able to use Edit and Continue as long as I wasn't attempting to edit lambdas or other items!
Find little solution for this case - close all files in solution before run debug.
Only files which were closed when debug is started can be edit.
Of file is opened when debug is start - edit is not possible.
What works for me, is the following:
1) Break point is hit, and I want to change code.
2) Now: Set next statement to somewhere earlier in the current function.
3) Do the change
4) Save / CTRL-s
5) Stepping through the function now includes the change.

vs2005 - Switching between design and source mode get stuck

I dont know if anyone else has had this problem. I'm using VS2005 working on a C# website.
The problem is on the .aspx page, when I click on the "Design" option two things happen.
It does not switch to design mode. I see only source. But I the problem is that the source mode gets stuck and uneditable.
Second thing is that I cannot switch back to source mode and hence am stuck only in that non-editable mode.
I tried to Reset my settings, but that hasnt helped.
Any ideas?
Try running visual studio in safemode. Launches Visual Studio in safe mode, loading only the default environment and services, and shipped versions of third party packages.
Try the below command in Start-> Run
devenv.exe /safemode
http://msdn.microsoft.com/en-us/library/xee0c8y7(v=vs.80).aspx

Why am I unable to Debug my ASP.NET website in Visual Studio?

I used to be able to attach to my w3wp process and Debug my web application, but this is not working anymore. I have no idea what changed to break this. I'm using Visual Studio 2008 SP1. And I'm debugging in IIS, not using ASP.NET's own server (i.e. I don't Run my project, I simply attach to a running process (w3wp).
My breakpoints simply have the "breakpoint will currently not be hit. The source code is different from the original version."
What I have tried:
Did a solution Clean.
Did a solution Rebuild.
Made sure that compilation debug=true in my web.config file.
Deleted the bin folder
Restarted Visual Studio
Restarted IIS
Restarted my Computer
Added a simple Response.Write to ensure that the latest DLL is being used. It is.
Made sure that Debug ASP.NET is checked in my project properties. It is.
Made sure that all my projects are compiled in my build configuration. They are.
But none of these help. I attach to w3wp, but my breakpoints never get hit.
Any ideas?
I had this problem recently and I ended up first making sure Visual Studio was not running at all on the system.
Then went into this folder and deleted all its content:
C:\windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\
Check your web.config for
<compilation debug="true">...
When you "Attach to process", the Output window should show you (when showing output from "Debug") all the libraries it's loading, and where it's loading them from - for the dll's in your /bin folder these are usually copied to the \Temporary ASP.NET Files\root\ folder - where are yours being read from? Have you definitely cleared them out from there?
The only other things I can think of:
You've compiled your code in "Release" mode rather than "Debug" (not the web.config) from the Solution Configuration drop-down.
The symbol files (.pdb) are missing from your /bin folder.
On the "Build" tab of the project properties, you are in configuration "Active (Debug)", you haven't check "optimize code"?
If you click "Advanced..." on that tab, what value do you have for "Debug Info"? Is it "full" or "none"?
Responding to comment
You will find it harder to debug successfully if your code compiled in "Release" mode, and you'll often get the "source code is different" message when you've not rebuilt the symbols (.pdb files) after changes - but you say you've done a clean/rebuild, so that should cover that.
Yes, your output window will show all the framework dlls that you're referencing as well as your code - but you should see one file listed in there with the name of each project output - those are the ones to look at.
You don't have some post build event that moves files into the correct directory for your site do you that's silently failing?
I also had this problem, solved it by changing the "Attach to" code type to Automatic on the "Attach To Process" dialog. (Previously I had this set to "Silverlight Code" due to debugging a different process... it can be easy to forget to change this back.)
I know this issue has been open for some time, but I think it is the same as I experienced:
I could not debug my .aspx server side code. I had a working WepApp AnyCPU project and I wanted to link to some x86 dlls, so I created an x86 debug target. Did similar things, rebuilt, stopped the development web server, rebooted, clear temporary files, all to no avail.
Fixed the problem by changing the target folder to bin\ (was bin\x86\Debug).
Are you running any add ins that could be affecting this? Or any tools that apply post build operations to the source code that the DLLs you start debugging with have been modified post build and it actually is correct that it's not the same source code so debugging won't work?
Also have tried resetting VS?
devenv.exe /resetsettings
Edit: if none of the information has aided you here, while painful it might be worth uninstalling and reinstalling VS and SP1. If you go through this and the issue is the same afterwards that atleast assures that the issue lies in either the web.config or the project settings.
Did you check your assembly.cs file with this attribute
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.Default)]
After reflecting a optimized code you will probably get this. So you must remove this to be able to debug again.
I faced the same issue. The w3wp process took a lot of memory and did not want to be reset on web application publishing.
Press Ctrl+Alt+Delete > Go to "Processes" tab > find w3wp process and
kill it. Run the app again (if this is an mvc app, just go to a
related url to automatically recreate w3wp process).
Warnings will disappear after that.
I have tried all the below options in my Visual Studio 2013 Update 4.
Reset IIS
Clean solution and rebuild
Delete the friles from temporary folder
C:\Windows\Microsoft.Net\Framework...\Temporary ASP.NET files
Check whether the compilation tag is debug or not
But none of them worked, here I am listing down the two things which worked for me.
Disabling the "Just My Code" option
Tools ->Options -> Debugging -> General -> Uncheck Enable Just My Code.
Edit the web.config file and save (You can always create a space in any line
in web.config, that will do)
Please be noted that this solution can be Visual Studio version specific, and the both fix worked for me in my Visual Studio 2013 Update 4.
in the "Attach to process" dialog, click the checkbox (near the bottom) for "show processes from all users" and if you see two w3wp.exe processes, try the other one.
One should have a comments/description value of something like T-SQL, managed somethingoranother. This is the one you want.
I have had this problem for a while and found my solution on the MS forum (link below).
Debug Diagnostic Tool was the culprit for me, but I did not have to uninstall it. I had a crash rule set up for the w3wp process and I simply removed that rule and restarted everything.
Microsoft Forum for Unable to attach error
On OpenVMS we just used to:
Compile/Debug then Link/Debug
and that was it! Simples!!
but seriously, make sure the file you have your Debugger.Break line in, has 'Copy always' set in its Properties before re-building
I was using the Visual Studio extension VSCommands to attach the debugger (convenient). However, IIS Express was running, and I guessed it might be interfering. Sure enough, when I closed IIS Express, suddenly I was able to debug again.
Joy ensued.
In my case I had a Console Application the hosted web page in .Net Framework 4.6.1. When I added a Debug to Conditional compilation symbols, it started to work:
Make sure that "Current Page" and not "Don't open a page. Wait for a request from an external application." is checked under Properties->Web->Start Action.
add this code in your .csproj file
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DefineConstants>DEBUG;TRACE</DefineConstants>
<Optimize>false</Optimize>
<DebugType>full</DebugType>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>

Edit source code when debugging

I have VS2005 and I am currently trying to debug an ASP.net web application. I want to change some code around in the code behind file, but every time I stop at a break point and try to edit something I get the following error message: "Changes are not allowed when the debugger has been attached to an already running process or the code being debugged is optimized."
I'm pretty sure I have all the "Edit and Continue" options enabled. Any suggestions?
This may seem counter-intuitive, but turn edit and continue off.
There might be another "allow me to edit read-only files" or "allow me to edit even when I am debugging...no really!" setting somewhere, but I don't have 2005 to look at to check.
In 2008, turn off edit and continue and you can edit while it's running (but those changes aren't appplied.)
If you actually want to use edit and continue, you also have to enable it for the project, on the web tab of the project settings.
The application is actually running off of a compiled version of your code. If you modify it it will have to recompile it in order for your changes to work, which means that it will need to swap out the running version for the new compiled version. This is a pretty hard problem - which is why I think Microsoft has made it impossible to do. It's more to protect you from THINKING some changes were made when they really weren't.
For Asp.net it is possible to think of two types of 'edit and continue'.
One is a classic edit and refresh the browser. This works because the browser refresh recompiles everything except precompiled code behind files. This is not referred to as Edit and Continue, though in practice it provides a similar effect. In this mode you cannot change code behind files, because they were precompiled and deployed, but you can change just about anything else.
Another mode allows you to change precompiled code behind files but nothing else ... (this is the mode Chris Bilson mentions which needs to be set on the project properties for ASP.Net). In this case you are using the Edit and Continue feature of the debugger, which knows preciously little about ASP.net. The debugger just sees a loaded .Net assembly and can modify it when stopped in the debugger because there is a project in the solution that claims to know how to build it. In this case you are prevented from modifying things that would otherwise mess up the debugging session. This method however is the only way to change the code while it is running rather than requiring a browser refresh.
You are allowed to make changes to the *.aspx file while it runs, and you can hit refresh on your web instance to see those changes immediately. However, you cannot make changes to the *.cs/*.vb or *.designer.cs/*.designer.vb files while the program runs.
I search for this on Visual Studio 2008 WAP (Web Application Project) and it took me two days to find the solution, so here it is in the hopes it helps somebody else:
There are two locations that have to be checked, one it under tools-options-debugging-Edit And Continue-Enable Edit And Continue, the other is right click project-properties-Web-Enable Edit And Continue
For the record, I had a similar problem with VS 2008 and a different solution resolved the problem for me. Editing code in Visual Studio 2008 in debug mode
Check that you are not in release mode.
In release mode you cannot edit your code while debugging. Just change mode to Debug

Resources