Visual Studio 2010:调试时无法复制文件
我有一段时间遇到问题了(我想是因为我使用的是 Visual Studio 2010)。当我尝试在 Web 应用程序上启动调试时,我随机从 VS.net 环境中收到此错误:
错误 1 无法将文件“obj\Debug\SolutionName.exe”复制到“bin\Debug\SolutionName.exe”。该进程无法访问文件“bin\Debug\SolutionName.exe”,因为它正在被另一个进程使用。
消除此错误的唯一方法是重新启动 Visual Studio(以便很快恢复错误,大约每天两次)。
在互联网上搜索了一下后,我发现可以从这里添加预构建 MSDN 链接
我发现的只是写下一些内容预构建事件并进行一些文件处理......好吧(无论如何它都不起作用)。
问题 1:有没有更简单的方法来解决这个问题(并且始终如此!)
问题2:这个问题的具体原因是什么?
I'm having problem from a while (since I'm using visual studio 2010 I think). When I'm trying to start a debugging on my Web Application, I randomly get this error from VS.net environment :
Error 1 Unable to copy file "obj\Debug\SolutionName.exe" to "bin\Debug\SolutionName.exe". The process cannot access the file 'bin\Debug\SolutionName.exe' because it is being used by another process.
The Only way to get rid of this error, is to restart Visual Studio (to get the error back soon something like twice a day).
After searching a bit on the internet, I found out thats it's possible to add a pre-buil, from here MSDN Link
All I found is to write down something in the pre-build events and do some file handling ... well (it do not work anyway).
Question 1 : Is there any easier way to solve this problem (and for allways!)
Question 2 : What is the exact reason of this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这与卷影复制有关。您可以在 web.config 中像这样禁用它:
如果上述设置对于预构建事件根本不起作用,您还可以使用解决方法:
您可以在 Windows 中完全禁用 ShadowCopy 服务,这样您就不会为所有解决方案设置这些值,但这会破坏很多功能,所以我不推荐它。
您始终可以使用自定义批处理脚本来由最后一个项目的构建后事件(根据构建顺序)调用,这将完成所有复制业务(我现在使用的)。
This is related to shadow copying. You can disable it like this in web.config:
You can also use a workaround if the above settings doesn't work at all with a pre-build event:
You can completely disable the ShadowCopy service in Windows so that you won't have to set these values for all solutions, but that will break a lot of functionality so I don't recommend it.
You can always use a custom batch script to get called by the postbuild event of the last project (as per build order) which will do all the copying business (which I use now).