Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

windows

dll

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

I found out using a tool called 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...

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...


  • 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.

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.


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

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


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