Visual Studio freezing (crashing) while loading solution - visual-studio

I've met with a strange problem. I had 7 projects in the solution. I had to add another MVC project. Now when the document (from the new project) is opened (for example HomeController.cs) and when this project is initializing at the start, it freezes the whole IDE like this:
(Some projects do not load)
After that, I have to kill the process. When I open VS again and fast click on another project (which is initializing) the freezing issue is gone. I have no idea what can cause a problem like this. I've tried with and without ReSharper but I get the same result. Also, I restored default settings of VS. Also repaired whole VS.
Maybe someone had the same problem and could give some helpful advice?

Usually removing of the hidden .vs folder in solution directory fixes the problem.

Possible solutions:
Delete .vs folder as mentioned above
Clear temp files from %USERPROFILE%\AppData\Local\Temp
Readjust source control in Tools -> Options -> Source control -> Plugins, set to None, Save, close VS. Then reopen it and reset the plugin.
There is no particular order, but one of them might help.

I experienced the same issue with VS 2019 and fixed it by deleting the user.json file from %USERPROFILE%\AppData\Roaming\Visual Studio Setup
EDIT
The issue reappeared after a few days, so I located the user settings for Visual Studio 2019 (%USERPROFILE%\AppData\Roaming\Microsoft\VisualStudio\16.0_f124b472) and deleting the following files seemed to have reset VS to a normal state:
Current.vsk
User.vsk
ObjBrowEx.dat
Please close all your solutions before deleting the files

I used to have this problem, it was solved just by double clicking any of the stuck projects. This nudges the loading process somehow and causes unloaded projects to complete its loading.

Delete the .suo file in the solution folder.
I am pretty sure I found this answer somewhere on Stackoverflow before, but now I can't find it anymore. Credits to whoever came up with this.

None of above answers worked for me and found this solution.
By opening solution in safe mode devenv.exe /SafeMode will show you details about file causing issue and then
Search for all the files in the project directory with extension *.user
and remove them all
last reloaded the projects

For Visual Studio 2019, I cleared my %USERPROFILE%\AppData\Local\Temp folder.
It worked.

When you get over the past install multiply versions and the previous version was not fully uninstalled. This cause this issue in my case.
Control Panel > Programs > Programs and Features
Search for all Visual Studio related programs and Uninstall those.

Related

Visual Studio “Go to definition” disabled or gray out

Visual Studio's Go To Definition is disabled and F12 doesn't work. Other commands like Alt-F12 may continue working.
Close the solution.
Delete the intellisense database file for the solution: [solution].ncb or [solution].suo
Reopen the solution.
Optional: Rebuild the solution.
Note that this can also be as a result of disabling database for C++/C#.
In Tools - Options, type "IntelliSense" into the search box, and click on C/C++ - Advanced. In the Browsing/Navigation section, change Disable Database to False, if it is not so already.
After re-enabling, close and reopen to force rebuild.
NOTE: IntelliSense will produce large files on disk (*.sdf and ipch) that should be excluded from Git, for example.
I know the solution has been resolved. However, I encountered the exact same problem. I searched internet. None of the trick works including this one.
Eventually, I figured out. I right clicked on the file that had the problem. I included the file in the project. Isn't that obvious. Actually not, the file has been included for a week. I have been working on that file more than 7 hours a day for the whole week. Up till yesterday 6:20 pm.
Oh, I could not compile correctly this morning. There were tons of syntax error message yesterday. This morning, I was able to compile. Strange. right? Then my go to definition was gone.
Took me a while to find out cs and designer.cs were certainly excluded, but aspx file was.
I solved the problem. Did my figure slip? I don't know.
That is one thing people check. Either yourself, someone else, or system accidentally exclude the cs files without the knowledge. I know it is strange, but it solved the problem. There are weird scenarios in Visual studio. People can present 200 solutions. They work for 99% of time, but not our cases. I just bring one more scenario
I encountered this in Visual Studio 2010.
For me, this solution did the trick
Close all the files.
Reopen the files.
and you are good to go.
This also happens, if Visual Studio has files opened, which are not in the current Solution.
I don't know how I got to this state, where files of a different solution where open as I didn't open them manually, but a quick check of the file path showed that those weren't files of the opened solution.
Therefore, "Go to Definition" was disabled.
I found that I had to remove my TFS mapping:
VS 2010 > open Team Explorer > Drill into the team project > double click source control > right click on the team project in the left pane and do "Remove Mapping" > after everything was removed I manually went to the local folder and deleted any lingering files > back in source control explorer I re-mapped to the same local folder and re-pulled all the code. Now the "go to definition" works again.
Not sure why I had to do this...
Check dll in references which is yellow. Remove it and add again.
I've just had this happen with a CMake-based C++ project in Visual Studio 2019. Everything was fine yesterday, then when I opened it up today all the Go To Definition/Declaration etc options were greyed out everywhere in every file in the project, even for things defined within the same file (and the syntax highlighting didn't look right either). It did work if I opened one of the .cpp files separately on its own (without loading the Project/Solution).
I tried various things including the answers here and telling it to generate the CMake cache again, but what finally fixed it was actually deleting the CMake cache. The Delete Cache option didn't seem to work (all the files were still there on disk, and there was some sort of failure message in the Output window) so I just deleted the entire "out" directory from the project directory (well, moved it somewhere outside of the project, just in case). Loaded up Visual Studio again, it rebuilt the cache again automatically and IntelliSense immediately started working again! I just had to wait 5 minutes for it to compile everything again when I wanted to run the project.
Maybe it wasn't necessary to remove the entire "out" directory, but when I clicked "Open in Explorer" under the "CMake Cache" menu it opened the actual build directory (which was the only thing in the "out" directory anyway) so I assumed the entire thing was related to the cache and was getting too fed up with it to try to narrow it down further. It's probably only certain files within that directory really.
Tried all the above solutions in my VS2019, nothing worked for me. Than I've noticed an update sign on the bottom Right corner. After updating the VS all options were restored.
Simple just check your bottom left corner of Visual Studio if Restricted turn it as a trusted and your problem will solve.
In my case due to my project is mapped with TFS so I am unable to go to definition also my project files showing read only when opening from Solution. So I have move to my root folder mapped with TFS and then right-clicked on folder > Go to properties > Attributes section was Read-Only I have unchecked it and clicked Apply. Reopen visual studio. Everything is now working fine.
I faced the same Issue in my Visual Studio 2019 version.I followed the below Steps:
Go to references folder in the solution.
Click on Manage Nuget packages.
Click on Browse.
Search for 'Microsoft.Net.Compilers'.
Click on Update.
This Worked for me.
In my case, another Visual Stuidio was opened (not closed succsessfully). Close all examples of VS, then re open solution.
Just open the Solution using Windows Explorer, instead of opening it from inside VS...

Cannot edit checked out file (TFS) in Visual Studio 2013

Since I changed my windows password I can no longer type into a checked out file in Visual Studio 2013! Where before I just needed to start typing and it would check out the file in the background, now it won't even allow me to type into the file after I manually check the file out, from the solution explorer! It's as if VS 2013 is ignoring the keyboard on the project under source control. It's fine for other projects even project's under source control!
I think I remember seeing this before with older versions of Visual Studio and resolved it with a "Go online" option but I can't see that option in VS 2013, or the project is not "off line" so the option is not available.
This is obviously related to the TFS setting on the project but I simply cannot get past it. I am blocked and would appreciate any suggestions.
I suspended Resharper and restarted Visual Studio 2013. Once I reopened it the problem was gone. Resuming Resharper caused the problem to emerge again.
The solution is quite large so maybe that is it. Before putting Resharper into suspend mode I tried switching off code analysis thinking the workload is just too great, but that didn't help. The suspend did though. I hope this helps anyone else with the same issue.
All I have to do now is to figure out how to get Resharper back in the game without the problem coming back. We rely on Resharper as it is an wonderful tool. Since the solution has many projects in it, I am going to try create a smaller solution with my web project and just reference the other projects as assemblies. Maybe that will help
Update:
Clearing the resharper cache as suggested by Alexander resolved the original issue.
I'd like to add Alexander's comment as answer, since it helped me exactly to solve the issue:
Clean R# (ReSharper) caches by deleting all folders (and files) from the path
C:\Users\{User Name}\AppData\Local\JetBrains\ReSharper\v8.2\SolutionCaches\
and then reopen the solution.
Note: (Thanks to Antak for providing this info!)
You can paste
%userprofile%\AppData\Local\JetBrains\ReSharper\v8.2\SolutionCaches
into file explorer's path textbox (open it via Win+E, or use Win+R and paste the path into the command window), this will resolve the physical path into your user's directory automatically.
This happened to me. All my JavaScript files went "dead." By "dead" i mean that all the normal VS intellisense coloring/functionality was gone; js files were un-editable, although Resharper was still working sort of; all other non-js files seems to be normal. In addition to Resharper, I had also previously installed Web Essentials and was using both tools.
First, I cleared the R# caches as mentioned above by Alexander. After restarting VS, this DID NOT work. JS files still dead.
Then i disabled Web Essentials. Then I restarted. THIS WORKED.
I then re-enabled Web Essentials, restarted again, and all seems to be OK. Am crossing my fingers....
I too had this problem with the latest version of ReSharper (9.0.0.0), but clearing the cache as stated above did not work. I actually had to go into my ReSharper options (ReSharper -> Options -> General) and click the "Clear Caches" button. Once I did this and restarted VS everything is working again.
Try: /safemode
I had a similar problem where I could not edit most of my files, but I could edit *.ps1 files.
I don't have TFS, I do have resharper and other plugins.
What worked for me was:
Start visual studio in safe mode: C:\..\IDE>devenv /safemode
Close VS.
Start VS normally.
That probably has the same effect as suspending and resuming resharper, but I'm not sure which plugin could be causing the problem. If you are having trouble this is something you could try.
I hit the refresh(restart) and it solved a similiar problems so maybe you better try that before an IDE restar. ctrl shift F5

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 not remembering open documents & startup project

For the past week, something has changed about my VS solution, and I havent found a setting to fix it yet.
When I close the solution and restart:
the start-up project reverts to a different one than was selected when I last closed
my project heirarchy is not what it was when it closed - every project is expanded
the documents that were open when closed are all closed
In each case I want the solution to look just like it did when I closed it last.
How do I make that happen?
Cheers,
Berryl
I believe this information all lives in your .suo file and/or .user file. If they've become corrupt, VS will struggle, so it'll revert to the default.
Maybe try exiting VS, deleting the .suo and/or .user files, start VS and set it up how you want, restart it again and see if it remembered the settings.
I ran into this problem in Visual Studio 2015. Removing the .suo file in the solution root did not fix the problem. I needed to remove everything under the following directory:
\\SolutionRootFolder\.vs\FolderWithSolutionName\v14\
.vs is a hidden folder and .suo is a hidden file under the v14 folder that must be deleted along with the vbcs.cache folder.
Update for VS2017: The problem still exists in VS2017 with the v15 folder.
This doesn't address the startup project issue, but checking the "Reopen documents on solution load" checkbox fixed the remembering open documents issue for me.
You can change that setting here:
Tools -> Options -> Projects and Solutions -> General -> Reopen documents on solution load
Not sure if that checkbox existed before I upgraded Visual Studio 2017 to version 15.8.3 or if it got reset somewhere along the way
In Visual studio 2015 :
Tools -> Import and Export Settings -> Reset all settings
It worked for me.
Happy coding :)
I had the same problem and tried removing the .suo file. However, that did not fix the project. I then tried the 'reset' option which worked perfectly.
I had the same problem with Visual C# express.
The only way I found to solve the problem was to:
reset the settings (Tools -> Settings -> Reset)
exit studio
delete the old corrupted .suo files from the solutions affected.
It looks like a VS bug since Express versions don't support any plug-ins anyway. I noticed that after I would delete the .suo file and reopen visual studio it would generate a new .suo file for that particular solution which would normally be around 57k. If I would open any file in the environment and then close visual studio (even if that file was not part of the solution at all) it would save a .suo which was around 916k. After that, opening that same solution would cause the problem described above.
In Visual Studio 2015 >> Tools > Options > Enviroment > Startup > At startup > Load last loaded solution
For Visual Studio 2017, Tools->Import and Export Settings-Reset All Settings did it for me after trying all other solutions as proposed.
Tried all of the above. Nothing worked. What worked for me (VS2017) is just going to my repo folder, show hidden files, delete the .vs folder and restart VS.
I solved this problem in Visual Studio 2010 Professional by invoke main menu command "Windows->Reset Window Layout"
Visual Studio 2015 Enterprise: As for many people in this thread, deleting the .suo file did not help, so I resorted to resetting all settings...which worked. I did not want to wipe out all of my settings, so I spent a bit of time to see which setting was causing it (note: still cannot find it in options).
So, to fix the issue while keeping most of your setting intact, follow these steps:
Tools -> Import and Export Settings...
Select "Export Selected Settings" -> Next. Check all checkboxes.
Expand "General Settings"
[Important] Uncheck "Window Layouts". -> Next -> Finish.
Back to: Tools -> Import and Export Settings...
Reset all settings -> Next -> just reset all settings.
Now import the settings file you exported in Step 4
Now you will have retained almost all of your settings, and fixed the problem. All you have to do now is move your pallets around to what you like and you're done!
Delete the .vs (Hidden) folder from the solution path and reopen the Visual Studio.
It happens when updating the Visual Studio.
For Visual Studio 2019 version 16.9.2, this problem occurs if you open a detached code window. Even if you close the detached code window before exiting Visual Studio, when VS restarts, no code windows are reopened.
This occurs regardless of whether you've deleted your "Solution User Options" (.suo) file or whether Tools->Options->Projects and Solutions->General: "Reopen documents on solution load" is checked.
It's slated to be fixed in version 16.10, hopefully.
Edit:
The VS dev community source ticket below denotes this issue is fixed in VS 16.9.6 and 16.10 Preview 1:
https://developercommunity2.visualstudio.com/t/Visual-Studio-not-restoring-prior-open-d/1317364
In Visual Studio 2017 the Tools -> Import and Export Settings -> Reset all settings worked perfectly for me.
Erasing the .suo file did not...
Even I solved this problem in Visual Studio 2015 Professional go to "Windows->Reset Window Layout" First i tried deleting .user/.suo file, but it was not wark out for me .Last i got solution like above.
For Visual Studio 2017 v15 go to Tools -> Options -> Project and solutions and chech "Reopen documents on solution load".
So nothing here fixed it for me. I am in VS 2015. Everything was find until I moved everything over to Windows 10. I did a reinstall of VS and started it up. It asked me what basic settings I wanted and I choose General. None of the projects I migrated over would remember their open windows. Sucked.
I followed every single bit of advice here and nothing worked. Worse even on Windows 7 it was carrying over.
So I decided to purge my settings and reset. When I did I was prompted with a dialog box to choose which default collection of settings I wanted. I chose visual c# and that fixed the problem instantly.
The initial problem was caused by my choosing "General" settings....
I have not tried the other settings. YMMV.
The only way I found to solve the problem was to:
reset the settings (Tools -> Settings -> Reset)
exit studio
delete the old corrupted .suo files from the solutions affected.
it works for me
Just close VS and delete .suo file then reopen VS and try

Visual Studio crashes when I try to open a solution under TFS source control

I am having some troubles opening solutions in VS2008 which are under source control by TFS.
opening solutions outside of source control works fine
opening single projects is OK
others can open these solutions
VS crashes without any notice, the logfile ends without any closing tags etc.
Anyone ran across this problem before me?
I've tried all the suggestions in here.
EDIT:
I've tried to run VS in SafeMode /ResetSkipPkgs etc. nothing helped and no error message was shown (Log and VS).
Edit2:
After trying all this I nuked my Visual Studio installation now it's working.
It may not be related at all, however, I had a similar problem once opening SourceSafe projects and the actual problem was related to the length of the directory structure.
By default, sourcesafe was getting my projects to my "My Documents / My Visual Studio" folder. This, coupled with the directory structure of the solution/project went beyond the directory length visual studio could manage and crashed. I seem to remember the crash not being particularly helpful / informative.
The solution was to ensure that all the SourceSafe working directories were setup in advance to a smaller D:\Projects type directory.

Resources