.net Visual Studio 中的错误,拒绝访问路径
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6750491/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
error in visual studio, Access to the path is denied
提问by Leon
I've been having this problem for a while now. I created a brand new winforms c# application in Visual Studio. I can usually launch it in debug mode once without a problem. However, if I close it and launch it again I get an error "Unable to copy file TestApplication.exe to bin\release\TestApplication.exe". Access to the path is denied.
我已经有一段时间有这个问题了。我在 Visual Studio 中创建了一个全新的 winforms c# 应用程序。我通常可以在调试模式下启动它一次,没有问题。但是,如果我关闭它并再次启动它,我会收到错误“无法将文件 TestApplication.exe 复制到 bin\release\TestApplication.exe”。对路径的访问被拒绝。
This is driving me crazy. Why is this happening? I noticed that the folders are marked as read only. However, when I try to change it nothing happens. My manager suggested that it could be the fault of some of the extensions that I've installed. I'm using Microsoft's power tools as well as AnkhSVN plug in.
这真让我抓狂。为什么会这样?我注意到文件夹被标记为只读。但是,当我尝试更改它时,什么也没有发生。我的经理建议这可能是我安装的某些扩展的错误。我正在使用 Microsoft 的电动工具以及 AnkhSVN 插件。
采纳答案by Conrad Frix
First check to see if you can delete the EXE. If you can't that means some process has a handle on it.
首先检查是否可以删除EXE。如果你不能,那意味着某些进程可以处理它。
Run Process Explorerand do a search for TestApplication.exe to find what it is
运行Process Explorer并搜索 TestApplication.exe 以查找它是什么
回答by lxwde
Have you tried enable windows service 'Application Experience'? This solved my problem after struggling for several days.
您是否尝试过启用 Windows 服务“应用程序体验”?经过几天的努力,这解决了我的问题。
http://www.codeproject.com/Questions/296249/Visual-Studio-2010-Access-Denied-Errors
http://www.codeproject.com/Questions/296249/Visual-Studio-2010-Access-Denied-Errors
回答by Schroedingers Cat
Do you have your bin folder included in your svn? In general, you shouldn't do this, for exacly this reason.
您的 svn 中是否包含 bin 文件夹?通常,您不应该这样做,正是出于这个原因。
These folders - bin and obj - are generated by VS, and so shoudl be regenerated if you check out the code again.
这些文件夹 - bin 和 obj - 是由 VS 生成的,因此如果您再次查看代码,应该会重新生成。
回答by Mangesh Pimpalkar
You can Run a program called Unlocker.exe which is a small program which unlocks the locked program.
您可以运行一个名为 Unlocker.exe 的程序,它是一个可以解锁锁定程序的小程序。
Try to unlock the exe which is locked and it will give you the exact program which is locking it.
尝试解锁被锁定的 exe,它将为您提供锁定它的确切程序。
This will help you pin point the problem.
这将帮助您找出问题所在。
回答by David R. Williamson
Have you tried running VS as an administrator? I've run into this problem recently and searched online to see if anyone has found an answer to it. The only thing I do that works is run as an administrator, but I hate having to do that.
您是否尝试过以管理员身份运行 VS?我最近遇到了这个问题,并在网上搜索,看看是否有人找到了答案。我唯一能做的就是以管理员身份运行,但我讨厌这样做。
[edit] I just read a subsequent comment by someone else about turning on Application Experience in services. That seems to have fixed it for me. I've been running on Windows client for years and just recently switched to Windows Server, which explains why I hadn't run into it before.
[编辑] 我刚刚阅读了其他人关于在服务中打开应用程序体验的后续评论。这似乎已经为我修好了。我多年来一直在 Windows 客户端上运行,最近才切换到 Windows Server,这解释了为什么我以前没有遇到过它。
回答by Gregory C Klein
I added a web service/reference to my Web Server and then my Visual Studio went all crazy and wouldnt recoginze and custom controls or web services. The pages worked for the end users.. Just had access / recognition issues in VS.
我向我的 Web 服务器添加了一个 Web 服务/引用,然后我的 Visual Studio 变得非常疯狂,无法识别和自定义控件或 Web 服务。这些页面为最终用户工作。只是在 VS 中遇到了访问/识别问题。
I saw a few posts to remove cache files in C:\Users\gklein\AppData\Roaming\Microsoft\VisualStudio\10.0\ReflectedSchemas - I did that but it didnt work for me...
我看到一些帖子删除了 C:\Users\gklein\AppData\Roaming\Microsoft\VisualStudio\10.0\ReflectedSchemas 中的缓存文件 - 我这样做了,但它对我不起作用......
What did work was when i recompiled the web server, there was an error about access to C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\remedy\7642007a\c5be7720\App_WebReference file/folder...
什么工作是当我重新编译 Web 服务器时,出现关于访问 C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\remedy\7642007a\c5be7720\App_WebReference 文件/文件夹的错误。 ..
My web server runs impersonating a global network user with elevated access rights...But they recently migrated my pc to a new domain where that user has no rights. The web site couldnt compile (as that user) on my pc. - Once I manually added that global network user as an admin on my pc... cleared cache and restarted VS.. IT WORKED!!!
我的网络服务器运行模拟具有提升访问权限的全球网络用户......但他们最近将我的电脑迁移到该用户没有权限的新域。该网站无法在我的电脑上编译(作为该用户)。- 一旦我在我的电脑上手动添加了该全局网络用户作为管理员...清除缓存并重新启动 VS .. 成功了!!!
hope my experience helps some else tooo
希望我的经验也能帮助其他人
回答by JimmyV
I recently had this issue. I manually deleted and replaced the file and continued to have the access error. I restarted my laptop and I was able to build and run my project.
我最近有这个问题。我手动删除并替换了该文件并继续出现访问错误。我重新启动了我的笔记本电脑,我能够构建和运行我的项目。
回答by JohnH
An XML file generated by my solution had the Read-only attribute set for a file version generated by another build. After the Read-only attribute was turned off for this file, my build ran without the path is denied error.
我的解决方案生成的 XML 文件为另一个构建生成的文件版本设置了只读属性。关闭此文件的只读属性后,我的构建在没有路径的情况下运行被拒绝错误。
回答by sunice
I had a compiled exe that refused to be removed despite using administrator account. I cant find Windows Experience in Windows 10. Found in in task scheduler.. oh man, it is a customer experience feedback tool i rather turned it off. used a free unlocker; looks and feels safe. the file was locked by system and could not be immediately deleted. chose the option to remove on next system restart. works perfectly. I dont usu post anything. but this route took me >1hr.. so if you have been been trying.. this could save your 1 hr.
尽管使用管理员帐户,我有一个编译的 exe 拒绝删除。我在 Windows 10 中找不到 Windows Experience。在任务计划程序中找到。哦,伙计,这是一个客户体验反馈工具,我宁愿将其关闭。使用免费解锁器;看起来和感觉都很安全。该文件被系统锁定,无法立即删除。选择了在下次系统重新启动时删除的选项。完美地工作。我不通常张贴任何东西。但是这条路线花了我 1 小时以上的时间。所以如果你一直在尝试……这可以节省你的 1 小时。
回答by colinD
Had this problem on Windows 10 and it was coming from Windows Defender Antivirus.
在 Windows 10 上有这个问题,它来自 Windows Defender 防病毒软件。
I excluded the folder containing the .exefile and it worked again.
我排除了包含该.exe文件的文件夹,它再次工作。
You can do that in Windows Security > Virus & threat protection settings > Exclusions
您可以在Windows 安全 > 病毒和威胁防护设置 > 排除中执行此操作

