'Receiving access denied error from Visual Studio when trying to change target framework
The error reads,
TargetFrameworkMoniker: An error occurred saving the project file 'yadayada.csproj'. Access is denied.
I'm trying to switch from .net 3.5 to .net 4.0 or higher.
The project is hooked into TFS in Visual Studio 2010 (also tried VS 2013, same error). I'm in a VM environment.
Any clues about this error? Google returns very little information. It seems like I have proper access to the file, but how is VS accessing it?
Solution 1:[1]
It sounds like either:
1)The file has been marked read only. Check this by viewing the properties of the csproj.
Or
2)Your user does not has sufficient permissions to change the file - check security on the csproj.
Solution 2:[2]
I have found that if you get the error, hit save, close visual studio and reopen the project you will find that 86.5% of the time the setting was changed.
Solution 3:[3]
Try running the Visual Studio in administrator mode and also check if your project folder is set to read only.
Solution 4:[4]
I got this error in my environment, which is straight VS 2013 Pro: no TFS and no VM. Unsetting the read-only box only changed the dialog display because reinvoking the dialog still showed read-only. I thought I changed the ownership of the project file to me by virtue of changing the ownership in a higher level directory and checking "Replace all child object permission entries with inheritable permission entries from this object." Of course the project file and everything else had inheritance turned off. Once that was corrected I was able to save things without being Administrator.
Solution 5:[5]
I was getting this error and it ended up being the app.config file, as well, that was write-protected. Changing the target framework not only changed
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
in the .csproj file but also changed the project's app.config:
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
(I wanted to add this as a comment to pixelmeow's Jun 27 answer, but StackOverflow policy prevents me from doing so until I have enough reputation points. I did vote for him/her, though!)
Solution 6:[6]
Deleting everything in bin file of the starting project did it for me.
Solution 7:[7]
I was getting this error and it ended up being the app.config file that was write-protected. Once I cleared the read-only property, everything worked fine.
Solution 8:[8]
I was getting this error in visual studio 2010 because of my start action setting. Each time I would hit debug, I think the browser window was trying to launch too fast (this is an ASP.NET MVC 4 with intranet settings project).. and I would randomly, sometimes consistently get access denied. So I changed the start action to: "Don't open a page. Wait for a request from external application."
And this seemed to fix the issue. You will just have to access the web application manually rather than VS launching the browser for you. You can click on the running server icon (bottom right of taskbar) and access the link from there if you don't remember it or your browser didn't store it as a history url for whatever reason.
Solution 9:[9]
I just encountered this error message in my Visual Studio 2022 Solution after updating to Version 17.1.5. I managed it to run again by closing VS and deleting/renaming the bin and obj folder. Restarting VS and the debug session ran without trouble.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow