Could not write to output file -- Access is denied
Asked Answered
S

6

16

I recently switched computers and copied all my projects over to my new local drive. I reformatted the computer I'm on now so it was pretty much a clean machine. Everything seemed to be working fine, but when I opened one of my projects that I had been running from my old machine, it would no longer compile, and I get the following error message: Could not write to output file 'c:\Users\user\Documents\Projects\RegressionWeb\OnetouchUpload\obj\debug\OneTouchUpload.dll' -- 'Access is denied.'

I'm getting an error like that for each project I have in my solution. I'm also getting this error: Unexpected error creating debug information file 'c:\Users\user\documents\projects\RegressionWeb\RegressionWeb\obj\Debug\RegressionWeb.PDB' Access is denied

I've searched high and low, and the only similar issues I could find online related specifically to ASP.NET and IIS, neither of which has anything to do with my project (My projects are class libraries of mostly NUnit tests with some support classes).

I am the administrator on my local machine. I have already taken ownership of every file in the project using takeown /f .\RegressionWeb /r /d y and also tried to ensure that nothing had a status of Read-only, but the following file threw an error when I tried changing the read-only property of it's parent folder: An error occurred applying attributes to the file: C:...\Regressionweb.sln.DotSettings.user Access is denied

Basically this project was working perfectly and had no errors from my old computer. After copying over everything, this DotSettings.user file will not be modified, and Visual Studio can't write to any of the dll files. I'm sure the answer must lie in a Visual Studio setting somewhere. Any and all suggestions would be greatly appreciated.

Storfer answered 16/8, 2013 at 15:38 Comment(5)
Have you checked if the file is read only?Milline
Yep. None of the files that are causing the errors have that attribute set. The parent directory seems to but none of the children, and when I try changing it, what I describe in the 4th paragraph happensStorfer
What about permissions? Have you confirmed you have read/write?Milline
Yes, I have permissions as both my current user account and as part of the admin groupStorfer
VerySleepy can use this file , for me closing it had resolve the issueRiyal
D
15

I think Karl has it right. I had a similar situation once, and what I did was delete the file in question, clean the solution, and then rebuild. If the project needs that file it should recreate it; in my case it didn't need it because it never recreated it, but the project ran just fine.

One other thing I would recommend; you may be selecting the read-only attribute of the parent folder off and selecting this setting to recurse through all sub-folders and files, but that doesn't mean that's what's happening. For all your sub-folders and files (especially the ones that are cropping up as errors) inspect each one individually and make sure the read-only attribute is off.

Differ answered 16/8, 2013 at 17:48 Comment(2)
Deleting the file(s) in question, cleaning the solution, and rebuilding is exactly what worked for me.Salonika
Any suggestions for when you cannot delete the file in question? When I try to delete via File Explorer, it tells me access is denied and that I need administrative privileges even though I am the admin. If I try unchecking parent folder's read-only property, I get a similar thing.Waltz
W
4

I was able to get this working by closing Visual Studio and then opening it again, but being careful to run Visual Studio "As Administrator". To do this, from the Start menu, right click on Visual Studio and choose "Run as Administrator".

Wellesley answered 19/9, 2013 at 22:7 Comment(0)
R
3

My money is on your files are read-only. Verify they are read-only and change them or add your files to a source control system and let them get handled by that.

Remit answered 16/8, 2013 at 15:41 Comment(3)
Would make sense, like I said the parent folder does have the read-only attribute set, but when I change it and select apply, I get one file that throws this error: An error occurred applying attributes to the file: C:...\Regressionweb.sln.DotSettings.user Access is denied which I ignore, but then when I check the parent folder, the read-only attribute is still setStorfer
This was the issue for me. Thanks, @DarianEverett .Karsten
I had this problem just now and your money was well spent. This was the problem in my case.Attack
A
3

it seems that the same error is sometimes displayed when the app pool user doesn't have access to the %TMP%/%TEMP% folder.

You'll need to grant IIS_IUSRS read and modify access over the temp folder of the user the app pool is running as.

This could either be the temp folder in the app pool user's profile, e.g. c:\Windows\ServiceProfiles\NetworkService\AppData\Local\Temp, or the system temp folder at c:\windows\temp.

Anabiosis answered 5/12, 2014 at 7:38 Comment(0)
S
1

See if it is related to this:Could not write to output file - Access is denied . That would be a bit of a bugger to track down. In this case the project is self-referencing the dll and preventing access to the file.

Sarto answered 16/8, 2013 at 15:55 Comment(0)
B
0

This has a very simple solution, you just have to make sure that your directory name(folder name) is not the same as your file name. I created a folder by the name Pointers, my code was in a file pointers.cpp. When I compiled the code it kept showing the same error. I just had to change the directory or folder name to L1_pointers. You can change it to anything you want and it worked.

Briscoe answered 13/12, 2022 at 20:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.