Strange! VS 2005 -Break Point is not being hit - visual-studio

I am using Visual Studio 2005.I am running my code in Debug mode only.But my break point is
not being hit.
I followed :
Cleared my solution and created the one again
Closed the VS and Opened it again
Restarted my PC and tested the break point
But i am unable to figure out the problem.
My Question is:
Is it due to any virus ?
Add-on feature in my IE 8.0 prevents this
My VS is Corrupted ?
I am having botn VS 2008 and VS 2005 installed in my machine so any version
conflicts?
Suggestion is needed.

It sounds like the problem you are having may be due to the source code and the .pdb files being out of sync with each other.
Try these steps:
Perform a "Clean" build in Visual Studio.
Shut down Visual Studio.
Delete any "bin" and "obj" folders in all of your project folders.
Delete the solution .suo file
Sometimes the solution .suo file can become corrupt (doesn't cause Visual Studio to indicate any errors, but usually leads to strange behavior). Nine out of ten times, deleting the .suo file clears any strange behavior in Visual Studio.
The trick about deleting the "obj" folders forces Visual Studio to truely do a clean build the next time it compiles. Doing a "clean" build in Visual Studio only deletes the compiled binary results, it doesn't remove any intermediate object files that may have been created that Visual Studio might be linking against. By manually deleting the "obj" folders, you delete those cached object files and force a true rebuild.

What kind of project is it (website, console app, ...) Are you running the project directly from visual studio, or attaching to it afterwards?
Usually when this happens to me, its because the assemblies that are being used to run the process I want to debug do not match the currently built assemblies from visual studio.
You mention IE8, so if this is a website, you should try to attach visual studio to the w3wp.exe process. Otherwise the breakpoint won't have any effect. Alternatively, run the website using visual studio.

If you hover over the breakpoint in Visual Studio, does it indicate an error? Common problems are that the code hasn't been built, or the DLL that contains the code isn't loaded into the debugged process.

Related

Visual Studio 2017 freezes on startup

When I start VisualStudio it frezzes on the start screen. But when I start it a second time while the first instance is open the second instance works fine.
It's not that important but what could cause that problem?
Not sure. Sometimes some Visual Studio extensions are locking up Visual Studio.
I think by default Visual Studio tries to update these extensions
that have been installed automatically.
Recently I was trying to run Visual Studio (at Home) and it would freeze if I tried to open a specific project. But I was busy, so I didn't pursue it further and did other things. Then a week or a few days later I tried to run Visual Studio (at home), and it locked up when I ran it. I tried really hard to fix it.
There is a way I don't like where you can delete all or most of the
extensions from the place Visual Studio installs them, but this is
messy, and it is easy to get rid of something you need, and may hard
to get it back where it works correctly again. So I now recommend against this since there is a better solution now, below!
I searched to find a solution, and someone on a Microsoft board I think said to run from a command prompt as Administrator: DEVENV /RESETSETTINGS, I tried that and it didn't work for me. Then I thought, run DEVENV /? to see what I can see, and I saw :
DEVENV /SAFEMODE
So I tried that and it worked! Note: it was still being run from the Visual Studio Developer Prompt as an Administrator.
Visual Studio loaded up correctly, and I was able to look at the
installed extensions.
Eventually I noticed that they all or a lot of them were disabled (probably because of this SAFEMODE parameter), and I noticed that it the most recently updated were at the top of the list. I noticed that a lot of them had been automatically updated by Visual Studio and started Uninstalling a bunch of the more recent ones, and reverted at least one of them, then later uninstalled it. Eventually, after about 6 to 10 uninstalls, I got it to where Visual Studio would load normally, without the /SAFEMODE parameter! Cool!
So I turned off the automatic updates, so this will never happen automatically again. If I load a new extension or update and existing one manually, I should always exit Visual Studio and reload it after not doing too many updates or installing too many extensions to see if these extensions allow Visual Studio to load.
Sometimes an extension will not freeze Visual Studio, but will have errors. The ones that are the big problem are the ones which prevent Visual Studio from loading all the way and freezing it up. But with the above solution, you can eventually, cleanly, uninstall all the latest updates or new installed extensions until you finally get Visual Studio to load normally!
This workaround should be more widely known, so I am putting my solution to it here. Hopefully what I found should help someone else who is in a hurry, without having a lot of time to burn trying to get Visual Studio running again without freezing!
I use Visual Studio Community 2017, and I got this same issue on startup until I stumbled on this solution that deals with some corruption in the .suo file. Before I open Visual Studio for the day, I first delete the .suo file in my project folder, and it starts up just fine.
It's in a folder called .vs next to the .sln file. You may have to go to folder options View and check "Hidden Items" in order to find this folder. Dig down in that folder and you'll find the .suo file. Delete it. When you startup the project in Visual Studio, it will automatically create a new .suo file. So you'll have to do this every time you reopen.

Why does it take sooo long to load my solution in Visual Studio?

We have a really big solution with more than 200 projects and thousands of files. Despite of that the solution used to load pretty quickly in Visual Studio 2010 as well as 2012. However, after copying the whole SVN repository to another location, loading and closing the solution suddenly took extreeeemly long. (I am talking about 30-60 minutes here!)
I found a solution myself and I wanted to share it here, hoping that it might save someone quite a few hours of research and staring at the "Preparing solution..." dialog.
When inspecting the devenv.exe process with Process Monitor, I found out that it is pretty busy with accessing the .svn directory. Here is what I did (and this somehow solved the problem):
Kill Visual Studio
Open Visual Studio without loading a solution
Disable AnkhSvn as Source Control plugin (Tools->Options->Source Control->Plug-in Selection->None)
Disable "Document Well 2010 Plus" (VS2010) or "Custom Document Well" (VS2012) in Productivity Power Tools (Tools->Options->Productivity Power Tools) - I read that somewhere and it might have helped as well...
Close Visual Studio
Delete the solution's *.suo file. This is located in the same folder as the solution itself. NOTE: You will lose several settings for your solution, like currently opened files, breakpoints, bookmarks, current solution configuration & platform (e.g. Debug x86) etc.
Restart Visual Studio
Load the solution - it was much faster now!
Close Visual Studio
Open Visual Studio without loading a solution
Re-enable AnkhSvn and the "Document Well"
Restart Visual Studio
Open the solution - it was still loaded in seconds!
I do not know which of these steps actually solved the problem. Probably, not all these steps are required, but I did not want to reproduce the problem to find out which steps may be omitted. :)
None of those helped me, what I did... I watch with ProcMon of sysinternals, filtering for devenv, and I saw a lot of entries of fussionlog. I had enabled fussionlog for debugging purposes some weeks before and didn't think in disabling it. I just had to disable fussionlog and the solution opened faster.
You can open the Visual Studio in the Safe Mode, and then check your plugin and source control settings after opening the project.
Safe Mode means "Starts Visual Studio, loading only the default environment and services."
How :
devenv /SafeMode
Or according to your path
"C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\devenv.exe" /SafeMode
source : https://msdn.microsoft.com/en-us/library/ms241278.aspx
In my case, the following worked without any of the intervening steps suggested:
Kill Visual Studio.
Start Visual Studio directly (i.e., not from the .sln file).
Then, from within Visual Studio, open the solution.
In my case this was all it took to make the problem solution load quite quickly, without the need for me to change any settings or delete any files.
fwiw, I realize this is a late entry, but I found that simply removing (deleting) my large number of breakpoints resolved the excessive load time and compile time.
This action reduced the size of the .suo file from 214MB to 977KB. Let VS handle the .suo file itself.
Compiling and loading now takes < 1 minute instead of 5-10 minutes for a solution with 35 projects. Visual Studio 2012 Pro, update 4.
None of the other answers worked for me. CI compile times were fine, but loading my solution in Visual Studio was taking almost two minutes. VS would then operate just fine until I closed and opened the solution the next time. Different versions of VS all showed the same problem and both safe mode and deleting the suo didn't help.
I ended up following the advice in http://geekswithblogs.net/akraus1/archive/2014/04/30/156156.aspx to use Windows Performance Recorder to instrument VS and find the problem. By looking in Windows Performance Analyzer under the "CPU Usage (Sampled)" section and adding the "Stack (Frame Tags)" column, I was able to dig into the usage of devenv.exe.
Turns out the hot path by count had Microsoft.VisualStudio.Platform.WindowManagement.ni.dll 23 calls down, and below that eventually Microsoft.VisualStudio.ServerExplorer.dll and Microsoft.VisualStudio.Data.Package.dll. That pointed me to look in Server Explorer in the UI and open the Data Connections tab. There I found hundreds of mistakenly added connections that came from the debug web.config's ConnectionString section. Removing those from web.config reduced the load of that individual project from 90+ seconds to almost instant.
I have a different cause for the slow loading of the projects.
My situation is utilizing Git and found that even switching branches was slower than it should be with project load.
Solution: Run Visual Studio as Administrator
Reason: Something with the Corporate laptop is not providing the needed Git tool access (it doesn't recognize that a git repository is in use).
I have not seen any issues with Git or my personal access to any of the project files or Git objects.
I tried the above, but it didn't solve my problem.
Here's how I got around this problem, hopefully it will work for some of you as well:
Open Visual Studio 2013 with no solution.
Create a new C# Console application and save it.
Close Visual Studio.
Reopen the Console solution created in step 2.
Close Visual Studio.
Reopen the solution that was previously hanging on the Preparing Solution dialogue. Mine opened right away, no more hanging.
Using Visual Studio 2015, I ended up creating a new solution, adding the existing projects.
Deleting the *.suo from gehho's answer helped in the past, but didn't help me in this case. There's also another .suo file in a hidden .vs folder at the root of the solution.
There are other answers here for Visual Studio 2015 Visual Studio 2015 is extremely slow
For my case it was due to TFS issue. It thinks that there are more than 5000 pending changes.
The fix is to force TFS to recheck. Go to Team Explorer -> Source Control Explorer and do "Get Latest" on the projects that have pending changes. For things that are already matching TFS, Visual Studio will actually not download anything to your PC. For things that are different with TFS, Visual Studio will let you know and ask you to reconcile the difference.
This is VS 2019 Professional.
In my case there were <import ...> entries in the project files that pointed to
paths no longer available making the loading of the solution hang indefinitely without any form of information give (Shame on Microsoft!).
I encountered this problem only recently (Mar 2021), using VS 2019. It literarily takes 30+ seconds to load the file (each).
It only effects the Layout files. I believe it could be to do with the links within the files. I have not had time to investigate them.
However, I am writing this to suggest that regardless of the cause of the problem, a simple solution is to right click on the file and open it with Notepad to get your work done.

Visual studio lost current code on sudden crash

My visual studio 2010 crashed when some carelessness [bit of madness] mistakenly pressed start button and my Acer timeline got unstable. Two projects where open at the time, one in visual studio 2005 [I have both 2005 and 2010 installed]. Unfortunately I lost all the codes I had done at the time along with those coded even weeks before. Now the project files in both the solutions are those weeks older. Amazingly, the .aspx pages are intact and .cs files are gone.
What can be done to get the lost data? Help please.
Thanks.
Guys TAKE CARE if your Visual Studio crashes, you need to check the backup BEFORE you restart Visual Studio and check if your files are ok! Many people complain that they lost work after a crash, and then they restart Visual Studio, and upon discovering that their code cannot be found in Visual Studio they then check the backup at the location
%USERPROFILE%\Documents\Visual Studio 2010\Backup Files\\
The order is important. Check the backup FIRST, before restarting Visual Studio. If you start Visual Studio and then open your old project it's probable that Visual Studio will overwrite the backup files for that project.
Securing the backup is your FIRST concern. Then start Visual Studio and open your project to see how much damage there is.
You can check:
C:\Users\<username>\Documents\Visual Studio 2010\Backup Files\<ProjectName>\
C:\Users\<username>\Documents\Visual Studio 2005\Backup Files\<ProjectName>\
More information can be found here:
Visual Studio 2010 AutoRecover Feature
I just had the same experience -- losing a source file during a BSOD. Very annoying!
No backup file could be found, and I searched the hard drive for a file containing the class name, but no backup was unturned.
However I was able to get back something resembling my code by decompiling a DLL from the bin/Debug folder using DotPeek. So if you had previously compiled your code successfully, you can get the code (without comments, and with some weird local variable names, etc) via decompilation.
I Had the same problem, I lost code due to BSOD.
the backup folder should store files not saved until they are saved whenever you save the files there are deleted.
I think that maybe they don't remain after a restart as it was empty in my case.
A very good file recovery tool is Recuva. It helped me once, didn't help me second time, though, because I noticed the data loss too late, and all recoverable data got overwritten.
So I used DotPeek, though you'll have to do a lot of work on the disassembled files, they are pretty weird.
Now I put my source tree in Google Drive, because it has file versions and keeps deleted files. Dropbox would do, too.
Git or any other VCS are not solution for this thing, because you cannot have crazy amount of meaningless commits.

How can I force Visual Studio 2010 to reload files and projects that have changed on disk?

I often use command line tools to do source control updates of files and projects that I have loaded into Visual Studio 2010. With previous releases when I did this I could force Visual Studio to notice and load the changes by doing a Save All. This doesn't seem to work in Visual Studio 2010.
I do have 'Detect when a file is changed outside the environment' checked in the Options window, but if I sit and wait it takes minutes or longer for the changes to be noticed.
How can I force 2010 to notice the changes in loaded source files and projects?
You can reforce reloading a project by unloading and loading the project.
Right-click the project and select Unload Project, then, when the project is unloaded right-click again and select Reload Project.
Note that this requires that all modified files in the project either be saved or the changes in the file be discarded.
It sounds like this could be the same problem that I experienced here. VS 2010 doesn't seem to pick up on file changes made outside the IDE (like if you add a file to the file system, and then click refresh in Visual Studio you don't see the new file, I experienced this on C++ projects).
You can refer here for the MS case, they claim they have fixed the problem in "the next VS release", which I assume would mean the first service pack for VS 2010.
Win7 shouldn't be a pre-requisite, though its possible an earlier edition (pre-SP1) of Visual Studio didn't work it. Upgrade always works, for reference the track changes option also needs to be turned on.

Visual Studio freezes when switching to debug mode

Strange Visual Studio (TS 2008) problem: The IDE completely freezes whenever I switch from Release to Debug mode in a specific project. It happens right as I switch, before I try to build or do anything else.
The whole thing started out of the blue, without any abnormal change I can think of.
I tried to clean the solution, but it didn't help.
Anyone ran into this before?
If everything has worked fine and then stopped, usually it means there was some problem even though it had passed unnoticed.
Things I would try one after another:
Check which files were changed (why and how) after update from a source control engine
Review the list of extensions and plugins. Try to disable all or some of them
Close Visual Studio and kill all the development processes: devenv, mspdbsrv, vcpkgsrv, msbuild, msvsmon, vshub, vstest etc
Remove .suo, .ncb, .VC.db, .VC.VC.opendb files of the solution as well as .vs directory, which sometimes cause problems
Remove project setting files, sort of YourProjectName.vcproj.DOMAINNAME.LOGINNAME.user or YourProjectName.csproj.user. The setting file name depends on a project kind you use
Run "C:\Program Files\Microsoft Visual Studio [vs_version]\Common7\IDE\devenv.exe" /setup or "C:\Program Files (x86)\Microsoft Visual Studio [vs_version]\Common7\IDE\devenv.exe" /setup for x64 environment
In some complex cases, it helps to remove user settings, located in home %USERPROFILE%\AppData\[Local|Roaming]\Microsoft\VisualStudio[vs_version] and in registry HKCU\SOFTWARE\Microsoft\VisualStudio[vs_version]
It should reset all things to the beginning state. If it won't work, so there are additional tools to investigate. Download Process Explorer and once IDE freezes, start the Process Explorer, find the devenv process, double-click on it and go to Threads tab. Check, which thread has the biggest switch delta in case of the freeze, double-click on it and take the name (or offset) of the top function. It gives additional info where the problem may be.
Moreover, sometimes it helps to repair Visual Studio in the "Add or Remove Programs" wizard in Control Panel.
Had this problem in 2017. I ran VS 2017 as Administrator and it worked.
I've encountered this in VS 2017 (15.8). Upgrade to the newest version (15.9 at that time) resolved the issue.
VS seems to be doing a lot behind the scenes and putting project-specific files in App Data and who knows where else. I had this experience: I had a project which had two sets of identical code in two different directories: one for production, one for development. The development project started hanging on debug, the production did not. Tried all kind of settings and deleting .suo files, but no help. So I renamed the directory that the development version was in and presto, eveything worked without hanging.
In my particular case, I tried many other answers with no luck. It turned out that a call to this was hanging the debugger:
Log4NetExtensions.AssertFail("Error");
I managed to narrow it down to this line of code by bring up the threads window under [ Debug > Windows > Threads ] and clicking on the current thread to browse to the line of code it was hanging on.

Resources