每当我试图复制4个文件到我的bin文件夹,停止主服务后,我得到一个文件(TexteDll)错误。错误是:

Cannot copy TexteDll: The requested operation cannot be performed on a file 
with a user-mapped section open

这可能是由于一些系统锁定。或者另一个进程正在使用这个DLL。当我在谷歌上搜索时,我发现重新启动系统可以解决这个问题。

有人能给出原因或者解决办法吗?我检查了TexteDll的属性(通用、版本、安全性等)。一切都很正常。


当前回答

Sometimes when you double click on a warning about the referenced assembly version mismatch between two or more projects you forget to close the assembly view window and it stays there among other tabs... so you end up with the assembly being locked by VS itself and it took me quite a lot of time to figure that out :) Be careful with the power VS provides ;) Another dummy scenario. Sometimes simply deleting the whole obj folder or just the file warned as the locked one helps out with this crappy error.

其他回答

关闭VS上的所有文档,并尝试重新构建。如果不工作,重新启动VS.此问题与DLL文件的锁有关。

这里发布的解决方案没有一个对我有效。它是devenv.exe (Visual Studio)锁定文件,但如果我重新启动它,它会重新锁定它。

奇怪的是,Windows不允许我删除文件(到回收站),但Shift+Delete(永久删除)可以。

Sometimes when you double click on a warning about the referenced assembly version mismatch between two or more projects you forget to close the assembly view window and it stays there among other tabs... so you end up with the assembly being locked by VS itself and it took me quite a lot of time to figure that out :) Be careful with the power VS provides ;) Another dummy scenario. Sometimes simply deleting the whole obj folder or just the file warned as the locked one helps out with this crappy error.

以上都没有解决这个问题。

有人在我的解决方案集中有一个项目在构建配置中使用x64 CPU。将其更改为Any CPU会导致构建使用新文件夹。我仍然不知道哪个进程对那个文件有锁。

如果是web应用程序,删除临时ASP中的文件。NET Files文件夹可能是一个解决方案。