title: Unable to load referenced library
body: <p>I get this error in Visual Studio 2008 when developing a ASP.NET Web Application Project.</p>
  
  <blockquote>
    <p>Unable to load referenced library
    'Path-to-DotNetNuke\bin\file.dll': The
    process cannot access the file because
    it is being used by another process.</p>
  </blockquote>
  
  <p>This is a DotNetNuke project with multiple modules. IIS loads all assemblies from /bin folder under the application root.</p>
  
  <p>The projects in the solution are in their respective /DesktopModules/ProjectName folders and compile to a bin folder under the project.</p>
  
  <p>The error occurs after I compile the solution and <strong>copy all the projects' dlls to the /bin</strong> with a script. Visual Studio does not let me recompile, but if I restart it, everything works ok. This is really annoying when recompiling and testing the whole solution. You have to restart Visual Studio between every recompile.</p>
  
  <p>I couldn't find any file locks with Process Explorer when Visual Studio shows this error.</p>
  
  <hr>
  
  <p>[UPDATE] There is an <a href="http://msdn.microsoft.com/en-us/library/ms998223.aspx" rel="nofollow noreferrer">old MSDN document</a> that tells you not to build all DLLs to a single folder if you reference any over 64KB DLL there. Particulartly, the document says:</p>
  
  <blockquote>
    <p>It causes the build process to fail
    with file lock errors when a
    referenced assembly exceeds 64 KB in
    size.</p>
  </blockquote>
  
  <p>We do have references to over 64KB DLLs in /bin folder and copying recompiled DLLs there seems to trigger this, at least with VB IDE's background compiler.</p>