title: Visual Studio 2008 locks dll in bin folder and doesn't let go of it
body: <p>I am working on a solution consisting of 8 .NET projects. Since I am practicing TDD, I have to re-compile my solution very often. Lately I have been getting the following error about every second time when trying to compile:</p>
  
  <blockquote>
    <p>Error 2   Unable to copy file
    "obj\Debug\Zeiterfassung.Tests.dll" to
    "bin\Debug\Zeiterfassung.Tests.dll".
    The process cannot access the file
    'bin\Debug\Zeiterfassung.Tests.dll'
    because it is being used by another
    process.  </p>
  </blockquote>
  
  <p>Zeiterfassung.Tests.dll is the dll generated by one of my projects (it's the unit testing project). It's always this dll that cannot be copied and causes the error. Everything else works fine 100% of the time. </p>
  
  <p>In about 9/10 times I can "solve" the problem by recompiling my solution again. But when the problem is getting really bad, the project just won't compile successfully no matter how often I try and I have to restart the IDE. </p>
  
  <p>I used microsoft's handle.exe to ascertain which process is locking the DLL and it is devenv.exe. I also tried deleting the DLL by hand and it really can't be deleted until I restart the IDE. </p>
  
  <p>Last but not least, I tried adding <code>&lt;GenerateResourceNeverLockTypeAssemblies&gt;true&lt;/GenerateResourceNeverLockTypeAssemblies&gt;</code> to my project as suggested in another forum, but this did not help. </p>
  
  <p>Please help! This problem is really starting to drive me nuts. </p>
  
  <p><strong>Edit:</strong> I might also add that I made sure my unit tests are finished when this problem occurrs. Still, the dll remains locked. I am running my tests via the Resharper unit test explorer. </p>