每当我试图复制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.

其他回答

你在运行杀毒软件吗?有可能是AV软件(或其他软件)正在使用文件映射api读取文件,这导致了问题。

这是一个不同的例子。似乎由于正在使用文件句柄,就会发生这种情况。我相信这就是为什么这个答案是有效的。对我来说,我有更多的项目。从命令行打开csproj,忘记了我让它打开。所以把手是锁着的。 Sysinternals有一个简洁的命令行工具,如果您偏爱命令行,则称为handle。你可以输入handle <你想要的任何文件或文件夹的部分名称>,它会告诉你什么程序(如果有的话)正在使用它。

由Sysinternals处理

关闭visual studio,删除bin,调试发布文件夹,重新启动visual studio项目。 这解决了我的问题

我在用Ant构建Dot Net应用程序时看到了这些错误。

在我的例子中,它是我们公司的备份软件,赛门铁克DLO代理。停止它并排除我的杀毒软件中的目录并关闭Visual Studio似乎有效。

我也有同样的问题,在我的情况下,似乎现有的输出文件被其他应用程序锁定。

你可以用OpenedFilesView检查哪个应用程序锁定了你的输出文件: http://www.nirsoft.net/utils/opened_files_view.html