VS2015 Changes my files whenever I open them - visual-studio

I'm not sure what setting has changed or what is going on here, but whenever I open a file in Visual Studio Community 2015 it shows pending changes immediately.
Does anyone know what is going on here? It's really getting annoying and keeps messing up my version control with all these changed files that haven't changed.

Dammit. Just found my answer. It's actually a plugin called PHP Tools that I use. It's changing the Line Endings to Unix LF on open. Changed it to "Keep Current Settings" and it's not doing it now.
Mystery solved.

Related

Visual Studio sometimes not saving files

I am getting an inconsistent error with Visual Studio 2015 that is severely hampering my productivity.
I am working on a very large application that I have pulled down from TFS. Sometimes when working I will try and save the file that I was working on, and have the asterix not go away and the file not save. This is despite running the application in Administrator.
Sometimes the solution is simply to rebuild the project and then try to save, however when this doesn't work I need close down visual studio and start up again, losing all my saves anyways.
This isn't too bad when I am working on .net files because the problem happens a lot less, and the solution is almost always to just rebuild, which is much better than having to re boot vs. However recently I have been working on javascript files within visual studio, and with them I get about one save, then the problems comes up, and rebuilding doesn't fix issue, causing me to have to reboot visual studio every save I make...
I have tried searching online for people who have faced a similar issue, or asked around my work, and no one seems to have ever had a similar problem. So hopefully, for my sanity's sake, someone knows what the heck is going on with my visual studio. Thanks!
I am currently running VS2019 16.7.2 and sometimes it just refuses to save no matter what I do. I try Ctrl + S, File -> "Save all", closing the window (which causes the changes to be lost) but nothing works.
Though for some reason when first I press the File -> "Save ... as" option in the menu and then cancel it, that releases the "save lock" and suddenly I am able to save again. Not really a satisfactory solution but at least all changes aren't lost. Maybe it will work on other versions as well?
I will give an answer to a problem which might not be exactly the same as the one reported by the author, but it is fairly close, and people searching for a solution to this problem are likely to arrive to this question.
In my case, in my entire solution containing thousands of files, there was only one particular file that Visual Studio was consistently failing to save when needed. As a result, after each commit, the "Git Changes" tab would not appear completely empty. All files would be committed, except this one file, which would appear as still uncommitted. So, I would have to manually save it and then amend the last commit in order to arrive at a completely empty "Git Changes" tab.
I thought that the problem might be due to some discrepancy between the letter case of the filename on disk (which is what the "Git Changes" view reports) and the letter case of the filename in the visual studio project file (which is what the "Solution Explorer" view reports) but it turns out that this was not it.
After much troubleshooting, I discovered that the following sequence of magical incantations solves the problem, I have no idea why:
In "Solution Explorer" locate the problematic file.
Rename the problematic file to something else.
Commit (with amend if you wish) the file.
Rename the file back to its original name.
Commit (with amend) the file again.
Restart Visual Studio.
The last step of restarting Visual studio is not strictly speaking necessary, but it is useful in case you have a letter case mismatch, because Visual Studio seems to be somehow caching filenames, (or at any rate not detecting that the capitalization of a filename has changed,) and restarting it makes it come to its senses.
I realize this is an old question but I had a similar problem with a solution file I had upgraded from Visual Studio 2015 to Visual Studio 2022. I was unable to save any changes to the solution, although the file was writable in notepad.
Deleting the section in the solution file as suggested by Richard Stanton's workaround fixed it for me!
developercommunity.visualstudio.com Workaround
Delete the following section from the solution file:
ProjectSection(FolderStartupServices) = postProject
{B4F97281-0DBD-4835-9ED8-7DFB966E87FF} = {B4F97281-0DBD-4835-9ED8-7DFB966E87FF}
EndProjectSection

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

VS2013 - Operation Could Not Be Completed

After installing Visual Studio 2013 and playing around with some of the new features, I noticed I'm unable to open a cshtml file in one of my MVC projects. If I try opening it in the default html editor, I'm receiving the following error
The operation could not be completed
Opening the file in another editor, IE: HTML (Webforms) Editor, opens the file without any issue. So it seems to be an issue with the default Html Editor.
I've followed various suggestions for how to combat this problem from previous versions of VS. If I delete all the solution's ".suo" files, and restart Visual Studio, the error changes to:
Object reference not set to an instance of an object
Once Visual Studio creates a new ".suo" file, the error message reverts back to the previous one.
I've tried doing a repair install on VS2013, however I'm still running into the same issues. Also, running VS in Safe-Mode did not work either. I tried creating a new MVC project, which failed during creation. With any of these errors, the windows event log does not contain any messages.
Has anyone else had this problem?
Just found your question here because it happened to me as well. Here's what I did and hopefully it will fix / help find the problem.
Deleted all .suo
Terminate IIS Express
Close VS2013 and re-open
Open your project and try to start it (F5)
You probably have an error on your web.config file. For me it was an <appSettings> being there twice.
Fixed the web.config file, save and boom, error is gone.
Hope it will also fix your situation.
Found a working solution here (tested with VS2015 Update 1):
https://github.com/aspnet/Tooling/issues/276#issuecomment-166650817
Close VS
Delete the content of %LocalAppData%\Microsoft\VisualStudio\14.0\ComponentModelCache
Open VS
I just figured it out. In my web.config, I had the following in my
<appSettings>
<add key="webpages:Version" value="2.0.?.?" />
</appSettings>
Changing this the value to "3.0.0.0" resolved the issue. I never had a problem with this on VS2010 or VS2012. It seems there is something in the IDE that is not handling this gracefully.
That worked for me for VS 2015 (command prompt as Admin):
cd C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE
devenv.exe /resetuserdata
Like most people here have mentioned, review your web.config file for duplicates. I was in a rush, just copied and pasted appSettings from another solutions without noticing the section existed already in the existing document. Then issue this thread relates to started to surface. I went back and consolidated the appSettings, saved, and the issue ceased to exist.
For me this error was resolved by setting the VS 2013 shortcut to "run as administrator".
Check for errors in your web.config file:
duplicate keys (app settings)
tags not closed or used multiple times
...
It is due to IIS Express not running from Visual Studio when you try to debug the aspx page.
Quick and dirty fix is to right click the your project and choose "Use Visual Studio Development Server" and then again right click and choose back to "Use IIS Express" will fix this problem. This way I will care about all the changes required in configuration file.
I also got this problem after using some Nuget package. The problem was a duplicate of appSettings. I merged them all and it worked.
There is also this thread that an MS employee has answered with possible cause:
This is a bug in the debugger. There is a race condition that happens when all of the following are true:
Script debugging is enabled in IE User is debugging IE and another process
The other process stops (hits breakpoint, step operation completes, stops at an exception, etc) at a moment when IE is not running script code
IE starts running script code at roughly the same moment that the user hits F10/F5 in Visual Studio.
The most likely
reason for this to happen is that the code from 'setTimeout' is run,
but I am not a JScript expert, so I am sure there are other possible
reasons as well.
and these workarounds:
If you hit this problem, I believe you could detach the debugger and then re-attach.
-or-
This problem happens when debugging ASP.NET and when script debugging is enabled in IE. If you disable script debugging in IE, or
toggle it on and off when switching between debugger server-side and
client-side problems, you would be able to work around the issue.
-or-
If your web application is using setTimeout, you may be able to avoid or at least reduce the problem by doing something to ensure that
script runs less often. This could mean increasing the timeout value,
or this could mean adding conditions around when setTimeout is used.
I had error in my web.config file, there was two spaces before <xml> tag. after removing it stopped showing this error.
I had the same error in VS 2015 running on Win 10. Fortunately fixed simply with a reboot. On restart it appears windows applied some updates in the previous session which broke VS somehow.
I got this error in Visual Studio 2015 but only after I installed ASP.NET 5 RC 1.
Installing Visual Studio 2015 Update 1 fixed the problem for me.
What solved my issue is this :
Type %LOCALAPPDATA% in Windows Explorer and go to Microsoft\XX.0 your version of Visual Studio then delete the folder ComponentModelCache
Restart VS and it worked like a charm!
This is due to an update made to GitHub which is reported in their forum
I was asked by a colleague to look at this problem. I tried all the proposed solutions and nothing worked. Eventually I found that they had done a project Update from svn and they had a conflict and ignored it. In one of the config files I found the conflict marked ".yours". I corrected this and all now loads without error.
In my case, the problem was due to my web.config's app settings include pointing to a file that doesn't exist:
<appSettings configSource="App_Config\MISSPELT-FILENAME.config" />

Visual Studio 2010 closes open files after git pull

We're using VS 2010 and GIT. Occasionally, after a git pull, all open files will close--seems like this happens when new files are added to the project. I can't seem to find a related file that shouldn't be in version control. Has anyone else had this issue?
I figured out a solution to this. It's a little annoying but it works around the tedious task of re-opening all of your tabs/files in VS.
When you get the VS warning that the Project has been modified outside of VS it asks if you want to reload the project. Choose "Ignore."
Next, save all your work, close VS and reopen your solution or project. All the files/tabs you had open previously will be open again and the updates to the project file, obviously, will also be loaded.
Another caveat to this is you lose all your "Undo" potential in your open files.
When a .vcproj file gets touched (not necessarily changed), all its opened files are closed and never reopened. Might this be what you are experiencing?
Check out
WorkspaceReloder.
It's a visual studio add in that will keep your files open upon reloading. It's tremendously useful and will keep you from having to go through those ridiculous steps. Productivity++.

How do I REALLY reset the Visual Studio window layout?

I had a plugin installed in Visual Studio 2008, and it created some extra dockable windows. I have uninstalled it, and I can't get rid of the windows it created - I close them, but they always come back. They're just empty windows now, since the plugin is no longer present, but nothing I've tried gets rid of them. I've tried:
Window -> Reset Window Layout
Deleting the .suo files in my project directories
Deleting the Visual Studio 9.0 folder in my Application Settings directory
Any ideas?
Have you tried this? In Visual Studio go to Tools > Import and Export Settings > Reset all settings
Be sure you back up your settings before you do this. I made the mistake of trying this to fix an issue and didn't realize it would undo all my appearance settings and toolbars as well. Took a lot of time to get back to the way I like things.
Try devenv.exe /resetuserdata. I think it's more aggressive than the Tools > Import and Export options suggested.
Also check Tools > Add In Manager and make sure there aren't any orphans there.
How about running the following from command line,
Devenv.exe /ResetSettings
You could also save those settings in to a file, like so,
Devenv.exe /ResetSettings "C:\My Files\MySettings.vssettings"
The /ResetSettings switch, Restores Visual Studio default settings. Optionally resets the settings to the specified .vssettings file.
MSDN link
I had similar problem except that it happened without installing any plugin. I begin to get this dialog about source control every time I open the project + tons of windows popping up and floating which I had to close one by one.
Windows -> Rest Windows Layout, fixed it for me without any problems. It does bring the default setting which I don't mind at all :)
If you want to reset the window layout. Then
go to "WINDOW" -> "RESET WINDOW LAYOUT"
If you have an old backup copy of CurrentSettings.vssettings, you can try restoring it.
I had a completely corrupted Visual Studio layout. When I tried to enter debug, I was told that VS had become unstable. When I restarted, my window layout would then be totally screwed. I tried restoring the VS current user settings in the registry from a backup, but that didn't help. However, restoring CurrentSettings.vssettings seems to have cured it.
There seems to be a bunch of binary stuff in there and I can imagine it gets irretrievably corrupted sometimes.
Note: if you have vs2010 and vs2008 and you want to reset the 2008, you will need to specify in command line the whole path. like this:
"C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe" /resetsettings
If you don't specify the path (like devenv.exe /resetsettings), it will reset the latest version of Visual studio installed on your computer.
I close them, but they always come back
When you say "they always come back" do you mean "next time you restart Visual Studio" or "immediately"?
One quirk of Visual Studio (at least VS2005) is that settings aren't saved until you exit. That means that if VS crashes at all while you are using it, any layout changes you made will be lost. The way around this is to always gracefully exit when you have set up everything like you want it to be.
Not sure if this will help your particular situation though.
I tried most of the suggestions, and none of them worked. I didn't get a chance to try /resetuserdata. Finally I reinstalled the plugin and uninstalled it again, and the windows went away.
If you've ever backed up your settings (Tools -> Import and Export Settings), you can restore the settings file to get back to a prior state. This is the only thing that I've found to work.
If you want to reset your development environment of your visual studio, then you can use Import and Export setting wizard. see this for all steps:
http://www.authorcode.com/forums/topic/how-to-reset-development-environment-settings-of-your-visual-studio/
Window -> Reset Window Layout didn't exist for me. For anybody looking in 2022 or later, I finally found the answer! The crucial information, buried in a VSCode update release note, was right at the bottom of this section. Here it is if the link breaks in the future:
If you'd like to reset all views back to the default layout, you can run Views: Reset View Locations from the Command Palette.

Resources