What causes Visual Studio to reload projects? - c#

Our team has a solution that has 15 projects that we all work on collaboratively using git for source control. Sometimes when switching branches Visual Studio simply updates the source files and the branch switch takes seconds(bounded by how fast I can type commands).
Other times though, when switching branches, Visual Studio will popup a dialog saying that it needs to reload all the projects and then I have to sit and wait for approximately five minutes while Visual Studio goes through this process.
I'm guessing that something we're doing with line endings is causing us to touch one of the Visual Studio specific files, and that causes the reload, only I'm not sure which one, or if that's even the right path to go down.
So my specific question then is, "What causes Visual Studio to need to reload projects?"

In fact it is quite easy:
Every file change will cause Visual Studio to reload the file, whether it has really changed, or not.
When changing a project file, it will reload the entire project.
Maybe git, or some other software, is updating some attributes of the file (so not the content). This might trigger the 'Visual Studio' file change monitor already. I have the same issue using TortoiseSVN.

Related

Why does Visual Studio 2022 suddenly stop showing errors?

As stated in the headline, Visual Studio 2022 suddenly stopped showing errors (and also I can't find public method and variables but that's another question).
I am working in Unity and suddenly it just don't want to cooperate anymore.
I tried closing the application and unity all together and restarted my computer, and nothing worked.
At the top of your screenshot you can see "Miscellaneous Files". This means that the file is not considered to be part of any project.
To see errors and IntelliSense, VS requires source files to exist within a project so that it knows:
What references exist (packages, assemblies, target framework)
What version of the language is being used
Various properties that influence analysis/analyzers
So for some reason your file is not considered part of a project. We can't see your Solution Explorer, so it's not clear why that might be. Most likely you've opened the file via "File | Open". Make sure you create the file within a project, or add it to a project.
One of the endless joys of working with Visual Studio are random inexplicable times it stops working the way it should. Usually these steps work:
Close VS completely
Ensure all bin and obj directories of all projects are cleared
In the same directory as your solution should be a hidden .vs directory. Delete this.
Reopen VS and your solution. You should be back to a normal state within a few moments. Sometimes a "Rebuild All" can accelerate its return to normality too.

Visual Studio errors disappear when open file

I'm in the process of updating a library in a larger solution. For this purpose, I have removed the old references in all projects and added new ones.
If I compile the solution now I get about 3000 build errors, which indicate that various classes are defined in the old, removed libraries and I should add a reference to them.
After I have opened a reported file, Visual Studio recognizes that these classes are also included in the new libraries and removes the error.
Now I don't want to open hundreds of files to make these ghost errors disappear, especially because the problem repeats itself after the next build.
Does anyone have any idea how I can get Visual Studio to stop reporting ghost bugs?
I'm using Visual Studio 2022.

Quick Actions and Refactorings not working in VS2015 Pro [duplicate]

My installation of Visual Studio was fine previously, but has started acting weird lately. Some of the symptoms include
Visual Studio randomly hangs or crashes
Visual Studio won't start
Intellisense disappears sometimes
Plugins are not working, or are failing to start
I can't install or uninstall tools
I can't connect to source control anymore
Certain known good project types fail to load properly
Known file types don't have syntax highlighting anymore
I can't add files to a solution because the option is greyed out
I can't add, remove, or update files to a solution due to an error
I can't add or remove projects to a solution due to an error
I can't open a solution due to an error
The debugger cannot launch, or attach to processes
I can't find any templates when I try to add a new item
I can't copy/paste due to an error
A DLL required by Visual Studio is missing or corrupt
Menus are suddenly empty
Something that I know should normally work, now does not work
How can I fix this?
(This question is meant to be a canonical close dupe for these types of questions)
Visual Studio is pretty reliable, and most of us using it aren't experiencing the issues you are. It's a pretty large and complex suite of components, though, which means problems are bound to occur.
First: Restart Visual Studio and, if that fails, restart your computer
The majority of small issues are fixed by restarting Visual Studio. Some of the ones involving connectivity or services can be fixed by restarting your computer.
If this doesn't fix your problem
There's no way to guarantee that something bad won't happen to a particular installation of Visual Studio. The ways a large, complex application can become misconfigured or damaged are too varied to mention.
The effort it would take to diagnose and track down every possible cause is great. Ain't nobody got time for that. The one reliable solution—which works almost every time it's tried—is:
Reinstall Visual Studio.
Go ahead, rest your eyes for a little bit. Come back when you've come to terms with this sad fact.
…
Resigned? Okay. We're going to go through the steps to fix your problem, starting with the lowest impact, but probably least likely to work, one first. While you are attempting to fix this, keep notes! Mentally, or write them down. If you get to the last step, you'll need them.
First, let's go the easiest route and return Visual Studio to its original state. We can do this by removing all extensions and by resetting all settings.
Open the "Extensions and Updates" dialog. If you can't find it, type that into the quick launch. If you can't find that, try ctrl-q. For each installed extension, highlight it and click the Uninstall button.
Next, let's reset those settings. Make sure you export them first!
From the docs:
To export your settings
1. On the menu bar, choose Tools, Import and Export Settings. Choose the Export selected environment settings option button, and then
choose the Next button.
2. Make sure that the check boxes for the kinds of settings that you want to export are selected and all other check boxes are cleared, and
then choose the Next button.
3. (Optional) Name your settings file, enter a different path where it should be saved, or both. By default, setting files are named
Currentsettings.vssettings and saved to %USERPROFILE%\Documents\Visual
Studio 2015\Settings.
4. Choose the Finish button.
You can import them later from the same location. Now, once you've saved your settings, go back and reset them.
Tools -> Import and Export Settings... -> Reset all settings
Having reset everything, try to repro your issue. Still breaking?
Heck.
There's no doubt that you need to reinstall. Let's go the easiest route and do a repair. Do the following:
Go to Control Panel > Programs > Programs and Features
Select Microsoft Visual Studio [whatever edition] [whatever year]
Click "Change"
Click "Repair"
After you've done this, try to repro your issue. Did it still happen?
Damnit, sorry.
If you want to try a different way, you may be able to do an "overlay" reinstall. Simply run the installer directly and select "install" (if this option is available to you). You can use your original media, but I'd strongly suggest you re-download the installer. This will overlay a new version over the old, without messing up your settings. After reinstalling, try to repro. Did it?
Aw hell. Here we go.
You need to try uninstalling/reinstalling. First, though, you might want to export your settings. You should have done this for step one of this answer, but if you didn't, go back and follow the instructions to do it now.
After saving them, repeat steps 1 and 2 (from the repair instructions) and this time select "Uninstall" instead of "Change". If your issue has to do with an external component, search for it in the list of other installed applications and uninstall it as well. If you're paranoid, uninstall everything Visual Studio related. They may be out to destroy you.
Now, reinstall Visual Studio. If you've found yourself at this point, you're in deep, so don't risk installing from your original media. Download a fresh, fully updated copy from where you originally got it. For example, if you got Visual Studio via your MSDN subscription, go there and download the ISO.
Now, having reinstalled everything, try to repro. Did it happen again?
F##&ing s#!t.
Now is the time to create a bug report. Go to Connect
https://connect.microsoft.com/VisualStudio/feedback/LoadSubmitFeedbackForm
Provide as much information as possible. You need to give them all the info they ask for in the form, plus details about the bug, how to repro it, and what you did to try and fix it. Remember those notes I told you to write down? Bust them out now. I'd strongly recommend you mark your issue public, as it may be found and commented on by others with your problem.
Within a day you'll get a response. They will probably want you to turn on Visual Studio logging and repro the issue. I won't tell you how to do this here, as they will give you exact instructions for the version of Visual Studio you are running. Follow them and reply as soon as you can.
There will be one of three outcomes from this process:
They will tell you that you're doing it wrong
They will discover an outside actor causing the issue
They will discover a bug
For #1, stop doing that, and you're done. For #2, they'll probably tell you to uninstall the bad actor (e.g., remove a plugin) and go tell the people responsible about the bug (don't slack--do it). For #3, they'll triage the bug and it will be fixed sometime later. It's likely they will suggest workarounds that will at least get you moving again, if it's a true bug.
And that's it. Now, go forth and reinstall Visual Studio!

Visual Studio freezing after debug session

I asked this question before in Visual studio not allowing me to edit file after debug session and at the time resetting the visual studio settings helped and solved the issue. This problem has returned however. Everytime after I finish debugging, VS will not allow me to edit one of the files I am working on (I am working on multiple screens). Furthermore, whenever I finish debugging, a "Customize" window will pop up.
I will try clicking on the file I want to edit after a debug session but I will not be able to click anywhere. The only way I can access the file is through the arrow keys, but this is highly inefficient since I also need to use the arrow keys to scroll. This usually happens in the same file as well. The only way to fix the issue is to restart visual studio, which is inconvenient. I have tried resetting all settings but this only worked for a short period of time. Is there anything else I can try?
I have run into issues with Visual Studio where something takes the focus of from the keyboard/mouse. I have resolved it by hitting Esc multiple times until Studio comes back.
The other action to try is to install service update 4 for Visual Studio 2013. If it is already installed, install it again, but choose Repair. Reboot if necessary.

My project in Visual Studio is Read Only. What did I do?

I must have done something wrong. I have a C# project in Visual Studio 2008. All of a sudden I see a lock on my classes and when I hover the class names on the top tab I see the class name as : C:\Myprojects\Oder.cs[Read Only] !
Has something weird like that happened to you before?
In my case it was a ReSharper 9.0/9.1 related issue. After clearing the ReSharper cache, I was able to edit files in my solution again.
Clearing the ReSharper cache can be done here: ReSharper -> Options -> Environment -> General and click: Clear Caches and restart your visual studio.
(The image is contained within the first of the linked JetBrains articles).
JetBrains instructions:
Ultimate Guide to Speeding Up ReSharper (and Visual Studio) - Performance degradation after ReSharper upgrade
ReSharper Online Documentation
A couple of possibilities spring to mind:
Have you added the project to source control?
Have you marked the project folder (and all it's sub folders) as read only?
Of course, someone else may have done either of these things if they have had access to your machine.
One Possible stupid thing.
Your project is still running and you forgot that. Stop debugging (CTRL + F5)
How do I know. Guess..
Restarting my computer worked for me. My project became read only in between compiles - suddenly I couldn't save changes to files, Visual Studio started presenting me with 'save as' dialog boxes, and SVN couldn't commit or clean the project because "sqlite could not write to readonly database." Checking the file properties on the files in Windows Explorer showed that none of them were marked read-only. I was able to make a backup copy of the project, then I restarted and it was fine.
Restart your Visual Studio and add the project again. Worked for me.
Close, then reopen the file.
Still a pain, but at least it's less costly than completely closing visual studio.
You can try: file -> Source Control -> Go online
IDE-integrated source control?
Sounds like your source files are or have been under source control. Many source control systems will set files to read-only when they haven't been checked out for editing.
Total Commander makes it really easy to change file attributes recursively, but most likely Windows can also do this :)
Much in line with what Morten Mertner said, (if you by chance are using TFS Source Control like I am) I did a manual checkout of the file and it resolved the issue for me.
For me the problem is that the files are locked while the application is running.
In this state, Visual Studio 2013 displays the lock icon in the file tab and when you try to edit the file, a dialog box with this message appears:
Changes are not allowed for this module as it was not built for changes while debugging or the target .NET runtime version does not support it.
In Visual Studio 2015 as well, the lock icon appears in the file tab when the application is running. but the dialog box and message are not displayed.
Stopping the application causes the file to become unlocked.

Categories

Resources