As one of the solutions I’m working is getting larger and larger (50+ projects), Visual Studio sometimes “forgets” to let go of its own handles:
Unable to copy file “obj\Debug\YOURASSEMBLY.dll” to “bin\Debug\YOURASSEMBLY.dll”. The requested operation cannot be performed on a file with a user-mapped section open.
I don’t know what a user-mapped section is to be honest, but after some digging and trying I found out that VS was still holding file locks on those DLLs and trying to open another handle to them – not working of course.
I first tried restarting VS using the good old motto “Have you tried turning it off and on again?”. It seemed to work, however, after 1 successful build, the same error popped up for another assembly.
Eventually, this is the way to avoid the error (for a while): clean your solution when the error comes around. Then, restart Visual Studio. Before you do anything else when it starts up, clean the solution again to make sure the files can be deleted.
If anyone finds the reason behind all this, please let me know.
Update: this does not solve my problem all the time.
Update 2: another user reported this as being a possible issue with Visual Studio Achievements, which I also have installed (Forum)
With the extension disabled, the error went away.