title: Why is Visual Studio failing to copy a dll to my web directory (IIS file locking issue)?
body: <p>What is causing these frustrating errors during every Visual Studio build operation?</p>
  
  <blockquote>
    <p>Could not copy "obj\Debug\mywebapp.dll" to "bin\mywebapp.dll".
    Exceeded retry count of 10. Failed. Unable to copy file
    "obj\Debug\mywebapp.dll" to "bin\mywebapp.dll". The process cannot
    access the file 'bin\mywebapp.dll' because it is being used by another
    process.</p>
  </blockquote>
  
  <p>I'm fairly certain that w3wp.exe is locking the file, because the error stops if I restart or shut down IIS from IIS manager.  ProcessExplorer shows that w3wp and visual studio are the only processes with locks on the file.  Obviously IIS is the issue, because the compilation succeeds when IIS is restarted.</p>
  
  <p>I am using dynamic assemblies loaded into a child application domain.  Could those be referencing the file?  I tried added an event handler to the Global.asax application_end event to ensure the child app domain is unloaded, but the handler never runs.  Also, the debugger's "modules" window shows various modules, but the AppDomain field is always blank, so I cannot even determine if that might be an issue.</p>