80

I have noticed a few times over the past months that sometimes I will use the little yellow lightbulb icon and right click it and select an option for it to fix something for me and then it just highlights what it was going to fix and pops up a message that says "Failed to modify Documents".

Has anybody had this problem?
Do you know how to overcome it?
It is almost as if resharper thinks that the document is read-only or something, even though I can manually edit the document.

John Saunders
  • 160,644
  • 26
  • 247
  • 397
Curtis
  • 5,794
  • 8
  • 50
  • 77
  • 1
    Are you using Git for source control? Which Git client are you using? – John Saunders May 09 '14 at 16:35
  • Yes. I am using GIT. I am using the TFS Microsoft client. – Curtis May 09 '14 at 17:09
  • 1
    For me it happened when I was doing a test project.The issue happened to be the fact that the root directory for git was configured for C:\Source and the test project had got created created in "C:\users\\Documents\Visual Studio 2013\Projects" which is the default path for VS 2013 for creating new projects.Obviously the default project creation path of VS doesn't lie inside the root directory of git source control so git fails to track the files as "untracked" status which results in this edit issue.When I moved my test project folder inside the root of git it got resolved instantly – RBT Feb 28 '16 at 02:12
  • 1
    Restarting Visual Studio normally does the trick for me – Robbie Dee Jul 17 '16 at 11:44

7 Answers7

176

Disable the Visual Studio source control plug-in.

  1. Tools -> Options -> Source Control
  2. Change "Current source control plug-in" from "Microsoft Git Provider" to "None"
Søren Gørtz Olesen
  • 1,775
  • 2
  • 10
  • 6
  • 12
    What happens if you want to use it? I assume the accepted answer would be fine? As long as it is in source (GIT) it doesn't matter? – bdwakefield Dec 03 '14 at 19:02
  • 2
    Thanks! I also had to restart visual studio for the fix to work. – Karle Jan 27 '15 at 15:31
  • 2
    If your project is using Git, you can't change the source control provider. However, the issue only seems to occur in files that are non-versioned; so use a git client (e.g. TortoiseGit) to add those files. Note that renaming a file in Visual Studio does not automatically revert/un-add the old name and add the new one, so you'd need to go around Visual Studio again to get a working environment back. – Zastai Apr 24 '16 at 13:53
  • Worked for me too. Unbelievable that this is a fix. The things I have to disable in VS2015 in order to get it to work properly is unbelievable!!! – Martijn B Sep 23 '16 at 22:45
29

I hade the same issue with Visual Studio 2013.
The solution was to add the project to version control (git in my case).

Now, you don't need make commits if you don't want to but simply add the solution to version control and the issue should go away.

Sani Huttunen
  • 23,620
  • 6
  • 72
  • 79
  • 2
    This sometimes happens when you add new projects in the directory that is not considered by VS (or more specifically - the MS GIT plug-in) as under GIT source control while the other projects are. This was the reason in my case. Moving the project directory bellow the solutions folder did the trick – Marek Apr 07 '15 at 11:25
  • I like the solution with disabling the Visual Studio source control plugin since its more common case. If project is added to source control then there is no problem at all. But if source control plugin is enabled and code is not added to a repo then this problem occurs. So for me its more logical to simply disable the source control plugin. – Roboblob Sep 02 '15 at 15:27
5

What did the trick for me was unloading and reloading the project in which the file that fails to be edited resides under. (Just right click on the project, and select "Unload Project" from the context menu.

Jonathan Perry
  • 2,953
  • 2
  • 44
  • 51
2

July 2022 Update:

Ran into this with VS 2019 after upgrading Resharper to 2022.1. Before the upgrade, the issue would not occur.

Uninstalled the Resharper, rebooted the computer, reinstalled Resharper (version 2022.1, the same that I was upgrading to) and it resolved.

HappyTown
  • 6,036
  • 8
  • 38
  • 51
1

I started VS 2013 as administrator and opened project and it works now fine.

xszaboj
  • 1,035
  • 7
  • 21
0

Allow me to chime in a bit late :

I solved this error by adding a .gitignore file and trying to commit my changes.

I cannot explain how this solved it, however, this happened to me on a completely new git repository. I've been using Git and VS for a few moth on another repository which has had a .gitignore file from the beguining and neither me nor anyone in my team had this problem before.

Seta
  • 93
  • 1
  • 6
0

Changing "Microsoft Git Provider" worked but I wanted a permanent solution.

I was already using GIT and had all the ReSharper stuff in my .gitignore. I was using VS 2015. When I updated to the latest version of ReSharper 2017.1.3 this issue started happening.

I made a backup of my solution folder (called it "repo_backup"), then cloned my repo fresh from git. Everything worked as normal again. I copied my changes into the new re-cloned repo, deleted the repo_backup, then continued on my way.

DrCJones
  • 179
  • 1
  • 4
  • 10