For one of my ASP.NET 3.5 applications, every single time I try to build the web app, it throws the following build errors in Visual Studio 2008:
Error 16
Removing the following lines from my app.config solved this for me - I'm using VS2010.
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="nunit.framework" publicKeyToken="96D09A1EB7F44A77" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-2.5.7.10213" newVersion="2.5.7.10213"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
I had similar issue and was able to resolve it by changing the 'AssemblyInfo.cs'
Visual Studio build fails: unable to copy exe-file from obj\debug to bin\debug
The issue ended up being that in the web.config someone had added:
hostingEnvironment shadowCopyBinAssemblies="false"
After commenting this out, everything started building ok. What a nightmare!!
I have battled this issue FOR YEARS!
Have you tried adding this to your PREBUILD Event?
if exist "$(TargetPath).locked" del "$(TargetPath).locked"
if exist "$(TargetPath)" if not exist "$(TargetPath).locked" move "$(TargetPath)" "$(TargetPath).locked"
See this for more info: http://nayyeri.net/file-lock-issue-in-visual-studio-when-building-a-project
Here's another thread, with more things to try...
http://social.msdn.microsoft.com/forums/en-US/Vsexpressinstall/thread/5b71eb06-5047-483d-8fd3-b75c102d41e9/?prof=required
This issue commonly occurs when you change your project from one directory to another . For the Shadow copy error you might have added this line in your web.config.To fix this follow the following
In your web.config file if there is something like
<hostingEnvironment shadowCopyBinAssemblies="false" />
change that into
<hostingEnvironment shadowCopyBinAssemblies="true" />
or remove it .Then it will work fine
Use ProcessExplorer to find out what process has the file open and go from there.
If a process is currently using those DLL, you can't delete and re-write it. You'll have to kill or otherwise stop the process using those DLLs while you compile.