windows 无法对打开用户映射部分的文件执行请求的操作

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4658354/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 07:57:42  来源:igfitidea点击:

The requested operation cannot be performed on a file with a user-mapped section open

windowsdll

提问by peter

Whenever I tried to copy 4 files into my bin folder, after stopping the main service, I am getting an error with one file (TexteDll). The error is:

每当我尝试将 4 个文件复制到我的 bin 文件夹中时,在停止主服务后,我都会收到一个文件(TexteDll)的错误。错误是:

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

It may be due to some system locking. Or perhaps another process is using this DLL. When I googled, I found that rebooting the system may resolve this.

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

Can anybody suggest a cause or solution for this? I inspected the properties of TexteDll (general, version, security, etc). Everything appears normal.

任何人都可以为此提出原因或解决方案吗?我检查了 TexteDll 的属性(一般、版本、安全性等)。一切看起来都很正常。

回答by Daniel Lobo

In my case it was the Explorer that was locking the DLL that was been compiled in the Debug folder... Strange, isn't it?

就我而言,是资源管理器锁定了在 Debug 文件夹中编译的 DLL... 奇怪,不是吗?

I found out using a tool called Unlocker.

我发现使用一种名为 Unlocker 的工具。

Had to delete with Unlocker, even when it was saying that there was no lock over the file, and I couldn't delete the folder until I didn't delete that single file...

不得不使用 Unlocker 删除,即使它说文件没有锁定,而且我无法删除文件夹,直到我没有删除那个单个文件......

After that it compiled.

之后它编译。

EDIT:

编辑:

I found out why in my case this was happening. I had the DLL opened in a text editor inside Visual Studio...

我发现为什么在我的情况下会发生这种情况。我在 Visual Studio 中的文本编辑器中打开了 DLL...

回答by Arman McHitarian

  • 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 提供的功能;)

  • 另一个虚拟场景。有时只需删除整个 obj 文件夹或仅删除警告的文件,因为锁定的文件有助于解决这个糟糕的错误。

回答by cihata87

close all documents on VS and try to rebuild again. If it doesn't work restart VS. This problem is related to lock of DLL files.

关闭 VS 上的所有文档,然后再次尝试重建。如果它不起作用重新启动VS。此问题与 DLL 文件的锁定有关。

回答by user2038221

Close visual studio, delete bin , debug release folder, and start visual studio project again. that fixed my problem

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

回答by bozydar.sz

I had same problem and in my case it appeared that existing output file was locked by other application.

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

You can check which application is locking your output file with OpenedFilesView: http://www.nirsoft.net/utils/opened_files_view.html

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

回答by guneysus

I am a developer and do not like apps injected to Registery like Unlocker. I used SysInternals Process Explorerwhich process locked my dll Find > Find Handle or Dll [Ctrl-F]and killed the process.

我是一名开发人员,不喜欢像 Unlocker 这样注入 Registery 的应用程序。我使用了SysInternals Process Explorer,该进程锁定了我的 dllFind > Find Handle or Dll [Ctrl-F]并终止了该进程。

回答by andrew.cuthbert

Others have already established that this error is due to another application having a lock on the file. Just wanted to point out that git difflocks files as well until you quit out of it. That's what caused this in my case.

其他人已经确定此错误是由于另一个应用程序锁定了文件。只是想指出,git diff在您退出之前,它也会锁定文件。这就是在我的情况下导致这种情况的原因。

回答by user10991945

I had the same issue. How I resolved it was:

我遇到过同样的问题。我是如何解决的:

  1. Open "Task Manager"
  2. End task "Explorer.exe"
  3. Click "File" --> Create new task -- Type in "explorer.exe" --> OK
  4. Clean my project and it works
  1. 打开“任务管理器”
  2. 结束任务“Explorer.exe”
  3. 点击“文件”-->创建新任务--输入“explorer.exe”-->确定
  4. 清理我的项目,它的工作原理

回答by t3chb0t

In my case I had to kill a hanging MSBuild.exeprocess that was locking the file (it was there even after I closed Visual Studio).

在我的情况下,我不得不终止MSBuild.exe锁定文件的挂起进程(即使在我关闭 Visual Studio 之后它仍然存在)。

回答by Eoin Campbell

Are you running any Anti-virus software. It's possible that the AV software (or some other piece of software) was reading the file using the file mapping APIs which caused the problem.

您是否正在运行任何防病毒软件。可能是 AV 软件(或其他一些软件)正在使用导致问题的文件映射 API 读取文件。