简体   繁体   中英

Unable to copy file. Access to the path is denied

I am working on asp.net 3.5 project on remote machine. I am accessing it using remote desktop. When I build the project, I get error:

Error   62  Unable to copy file "obj\Debug\myprojname.pdb" to "bin\myprojname.pdb". Access to the path 'bin\myprojname.pdb' is denied.

Project is under SVN. I deleted the obj\\Debug\\myprojname.pdb and tried to run again but getting same error. I am trying to remove thereadonly from the folder but after clicking ok, It becomes readonly again ( i guess because of SVN).

我通过从 bin 文件夹中删除有争议的文件并重建项目来解决这个问题。

我通过取消选中文件夹设置上的Read-only复选框选项来解决它。

I had the same issue and I only had to restart the visual studio. Classic move :)

我以管理员身份启动了 Visual Studio,这奏效了。

Removed read only flag on whole solution and it worked. Visual Studio 2012+TFS 2013

For me, my issue was that my AntiVirus had a handle on the referenced .dll that was used in my solution. Not exactly sure why, plan on researching it later. But killing my AV Service that had the handle, then restarting Visual Studio fixed this issue for me.

Hope this helps those of you who are maybe having to restart your entire PC when this happens, as before I figured this out, it was the only fix to my solution as well.

I had this issue with WebActivator.dll

Closing VS and reopening resolved the issue for me

如果所有其他方法都失败了,请尝试重新启动计算机 - 只有对我有用的方法。

Just found this , which worked for me:

Make sure bin isn't checked in to TFS.

我通过取消选中文件夹设置上的只读复选框选项来解决它。然后再次重新加载解决方案:)

只需从引用中删除相应的引用(.dll 文件),然后使用添加引用选项将其重新添加回来。我遇到了类似的错误,我已经通过这种方式解决了它。希望它会有所帮助。

After trying all the options below, the only solution was to restart the Windows 7 .

  • Removed read only flag.
  • Restart the visual studio.
  • Remove the corresponding reference(.dll file) from the References and add it back
  • Make sure bin isn't checked in to TFS
  • Deleting the contentious files from bin folder

我通过在 VS 2012 中从我的项目中排除我的 bin 文件夹来解决它。右键单击 BIN 文件夹并选择“从项目中排除”。

If you only get this for select files :

  1. Go to Published file folder
  2. Select the problem Files
  3. Properties
  4. Uncheck Read-Only

Apparently this can occur when Source Control non-checked out files are read only, and then someone just copies specific files .

(I tried other people's suggestions: giving myself write access to wwwroot, running VS as admin, but for me it was the read-only that did the trick. I specify this answer to point out it is the files at the destination you are trying to publish to.)

If you have done some check-in into the bin folder then this issue will come. Just delete that file and check-in again and build it. It will definitely work. Note: Please don't check-in anything into bin folder

the error is pretty obvious there Access to the path 'bin\\myprojname.pdb\\' is denied. the user the web console process is running under (not the user you created in the webconsole, the actual windows user), most likely "Network Service" doesnt have permissions to that folder.

You can either - Right click on that folder, goto permissions and add the "Network Service" user - Right click on that folder, goto permissions and add the "Everyone" user

that should fix that problem.

You might be opened two visual studios for two different solutions. Vs-A is in Debug mode and VsB is erroring out about .pdb file access denied. So remove the debug mode from Vs-A and Rebuild Vs-B. It should work now, without errors.

Good Luck.

我通过单独清理所有项目然后按照它们相互依赖的顺序单独重建它们来解决它

I was facing this issue, To resolved this i went through below things

What Didn't work

1) Read/write permissions were given to directory 
2) Restarted visual studio
3) Tried deleting visual studio temp files

What worked at last

Just paste the command given by Fred Morrison into the "Package Manager Console":

Get-Process | Where-Object -Property Name -EQ 'VBCSCompiler' | Stop-Process -Force -Verbose

Note: Just an observation Restarting Visual studio might not work in this case but restarting system can because stoppin process "VBCSCompiler" was the solution so we can do it either way.

Suprisingly, using

Thread.Sleep(1000); 

was the reason the project failed to compile for me with the same error message. Converting to

Task.Delay(1000).Wait();

solved it. Command line application, .NET 4.7.2

Tip for VS noobs like me: Check you're looking at the right /bin folder.

Details: To me, "Failed to copy from SomeDependancy/bin/Debug to /bin" sounds like it means the destination is SomeDependancy/bin. But in my application it meant MainProject/bin. I cottoned on to the idea when I discovered I could build the dependencies and only MainProject was failing. I haven't completed testing yet, but it looks like the suggestion about recreating the folder might now work for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM