简体   繁体   English

无法将文件obj \\ Debug复制到bin \\ Debug拒绝访问路径bin \\ Debug \\

[英]Unable to copy file obj\Debug to bin\Debug Access to the path bin\Debug\ is denied

I created simple wpf application (WpfApp1). 我创建了简单的wpf应用程序(WpfApp1)。 I run it and everything was working fine. 我运行它,一切都很好。 Then I tried to rebuild the solution and I received an error. 然后,我尝试重建解决方案,但收到错误消息。

Error: Unable to copy file "obj\\Debug\\WpfApp1.exe" to "bin\\Debug\\WpfApp1.exe". 错误:无法将文件“ obj \\ Debug \\ WpfApp1.exe”复制到“ bin \\ Debug \\ WpfApp1.exe”。 Access to the path 'bin\\Debug\\WpfApp1.exe' is denied. 拒绝访问路径“ bin \\ Debug \\ WpfApp1.exe”。

I restarted VS, cleaned and rebuilt the solution, checked by 'handle' if anything was blocking WpfApp1.exe file (handle "pathToTheFile\\WpfApp1.exe" 我重新启动了VS,清理并重建了解决方案,并通过“句柄”检查了是否有任何东西阻塞了WpfApp1.exe文件(句柄“ pathToTheFile \\ WpfApp1.exe”

result: Nthandle v4.1 - Handle viewer Copyright (C) 1997-2016 Mark Russinovich Sysinternals - www.sysinternals.com 结果:Nthandle v4.1-句柄查看器版权所有(C)1997-2016 Mark Russinovich Sysinternals-www.sysinternals.com

No matching handles found.) 找不到匹配的句柄。)

and I checked permission to the folder by right clicking on the folder -> properties -> security (3rd tab). 然后右键单击文件夹->属性->安全性(第3个标签),检查了对该文件夹的权限。 I'm logged under local account with administrator privilages and I'm able to create, rename etc. other files in \\bin folder but I'm not able to do anything with WpfApp1.exe file. 我已使用管理员权限在本地帐户下登录,并且能够在\\ bin文件夹中创建,重命名等其他文件,但无法对WpfApp1.exe文件执行任何操作。 I also run VS as an administrator and tried to do the same, but the error apeared. 我还以管理员身份运行VS,并尝试执行相同的操作,但该错误消失了。

I work on: win10 home, visual studio 2017 community (15.4.0) 我致力于:Win10 Home,Visual Studio 2017社区(15.4.0)

EDIT: repair and reinstallation of VS hasn't helped. 编辑:VS的修复和重新安装没有帮助。

After rebuild proces, .exe file from \\bin is set as deleted, but somehow the file still exists on the disc as a 'ghost' file. 重建过程后,来自\\ bin的.exe文件被设置为删除,但是不知何故该文件仍以'ghost'文件形式存在于光盘上。 In that moment access rights to the file are changed by OS and an owner of that file is unknown (I can't see it because of lack of permission. Before rebuild proces I had full access to the file.) If I restart OS, then the proces of deletion of the file is completed and the file doesn't exist anymore. 在那一刻,操作系统会更改对该文件的访问权限,并且该文件的所有者是未知的(由于权限不足,我无法看到它。在重建过程之前,我具有对该文件的完全访问权限。)如果我重新启动操作系统,然后删除文件的过程就完成了,该文件不再存在。

I had that error, it was unable to copy it, other times saying it was unable to delete it. 我遇到了那个错误,它无法复制,而其他时候却说它无法删除。 (and bear in mind there is the obj\\debug\\blah.exe and the bin\\debug\\blah.exe and the issue can potentially apply to both of them) (请记住,存在obj\\debug\\blah.exebin\\debug\\blah.exe ,这个问题可能同时适用于两者)

I think what happens is visual studio first tries to delete it(them) and if that succeeds(or if it's already deleted), then it tries to copy it. 我认为发生的情况是Visual Studio首先尝试删除它(如果它们成功了,或者如果它已经被删除了),然后尝试复制它。

You can try to delete it yourself and then you see there's some issue with deleting it.. So you can try closing explorer windows, and using eg unlocker and file governor. 您可以尝试自己删除它,然后看到删除它存在一些问题。因此您可以尝试关闭浏览器窗口,并使用例如解锁器和文件调控器。 I think you will find that it's probably not visual studio that is locking it. 我想您会发现锁定它的可能不是Visual Studio。 When I tried closing visual studio I still couldn't delete the file, so I can see that visual studio would have an issue deleting the file! 当我尝试关闭Visual Studio时,仍然无法删除文件,因此我可以看到Visual Studio在删除文件时会遇到问题!

Supposing you manage to delete it so visual studio would manage it or not need to. 假设您设法删除它,以便Visual Studio可以管理它或不需要它。 So now there's the error about it not being able to copy the file. 因此,现在存在无法复制文件的错误。 I see you checked permissions on the directory..that's good And if you find you get an error along the lines of not being unable to write to the directory, it may be a permissions issue , or it may be being low on disk space! 我看到您检查了目录的权限..很好,如果您发现无法无法写入目录的错误,则可能是权限问题,或者磁盘空间不足! Though I see in your case it was an anti-virus locking the file and the program you were using to check handles didn't pick that up. 尽管在您的情况下,我发现这是一种防病毒功能,可以锁定文件,而您用来检查句柄的程序却无法正常工作。 But this answer shows some other causes and approaches that may be helpful to others that have the issue. 但是,此答案显示了其他一些原因和方法,它们可能会对有此问题的其他人有所帮助。

Added 添加

Another cause is a known issue with certain anti-malware, such as Malware Bytes see here . 另一个原因是某些反恶意软件的已知问题,例如Malware Bytes see here You can go to the bottom right tray icons and hover over them to see what they are, see if any anti-malware is running. 您可以转到右下方的任务栏图标,然后将鼠标悬停在它们上方以查看它们的内容,查看是否正在运行任何反恶意软件。 Try quitting if it is and see if that helps. 尝试退出是否有帮助,看看是否有帮助。

And another possible cause that has also been shown to affect visual studio when building a project, is the "Application Experience" service which is in Windows 7/8/10 and should apparently be started. 在构建项目时,还显示了另一个可能影响Visual Studio的可能原因是Windows 7/8/10中的“应用程序体验”服务,显然应该启动它。 Apparently it is 'stopped' for many people. 显然,对于许多人来说,它是“停止”的。 Windows 2008 R2 - Kernel (System Process PID=4) is locking files and folders Windows 2008 R2-内核(系统进程PID = 4)正在锁定文件和文件夹

@HansPassant your clue regarding to McAfee was correct. @HansPassant有关McAfee的线索是正确的。 Only there was required to restart OS also. 也只需要重新启动操作系统。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法将“obj\Debug\Program.exe”复制到“bin\Debug\Program.exe”。 超过重试次数 10。失败 - Could not copy "obj\Debug\Program.exe" to "bin\Debug\Program.exe". Exceeded retry count of 10. Failed VS2017 Nuget软件包在编译时已复制到bin \\ debug但未复制到bin \\ release - VS2017 Nuget Packages copied to bin\debug but not bin\release on compile Visual Studio无法写入输出文件'... \\ _ \\ netj \\ Debug \\ Foo.Bar.dll“ - Visual Studio Could not write to output file '…\obj\Debug\Foo.Bar.dll" 不断得到:调试错误BC31019:无法写入输出文件'path / form.exe系统错误&H80070005&VB.NET - Keep getting : Debug error BC31019 : Unable to write to output file 'path/form.exe System Error &H80070005& VB.NET 尝试调试Java代码 - Trying to Debug Java Code 无法在 Visual Studio 中调试 - Cannot Debug In Visual Studio Visual Studio 在调试中编译,发布失败(“无法打开包含文件”) - Visual Studio compiles in Debug, fails Release (“Cannot open include file”) 如何快速调试C ++包含文件问题 - how to quickly debug C++ include file problems PBXCp错误:/…/Pods/Pods.debug.xcconfig:没有这样的文件或目录 - PBXCp Error : /…/Pods/Pods.debug.xcconfig: No such file or directory 初学者试图调试一个简单的程序 - Beginner trying to debug an easy program
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM