<p>I get the following error in Visual Studio 2005 when doing a build:</p>

<blockquote>
  <p>Error 9   Cannot register assembly
  "E:\CSharp\project\Some.Assembly.dll"
  - access denied. Access is denied. (Exception from HRESULT: 0x80070005
  (E_ACCESSDENIED)) project</p>
</blockquote>

<p>It happens only intermittantly and does go away if I restart the IDE, however this is incredibly annoying and I would like to put a stop to it happening permanently, if I can. I've checked the assembly itself, and it is not set to read only, so I've no idea why Visul Studio is getting a lock on it. I am working in Debug mode.</p>

<p>I've had a look around google, but can't seem to find anything other than "restart VS". Does anyone have any suggestions as to how I can resolve this annoying problem?</p>

[{'answer_id': 81080, 'author': 'Raithlin', 'author_id': 6528, 'author_profile': 'https://Stackoverflow.com/users/6528', 'pm_score': 3, 'selected': False, 'text': '<p>It sounds like you have a DLL that gets locked every now and then, preventing VS from overwriting/locking it. Have you tried using tools like Process Explorer (<a href="http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx" rel="nofollow noreferrer">http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx</a>), or Unlocker (<a href="http://www.emptyloop.com/unlocker/" rel="nofollow noreferrer">http://www.emptyloop.com/unlocker/</a>) to see what is locking the DLL? Unlocker in particular has saved me many a time.</p>\n\n<p>As noted in the comments below (Thanks <a href="https://stackoverflow.com/users/1/jeff-atwood">Jeff</a>), you can also kill an individual lock from within Process Explorer.</p>\n'}, {'answer_id': 53152824, 'author': 'AlainD', 'author_id': 2377399, 'author_profile': 'https://Stackoverflow.com/users/2377399', 'pm_score': 0, 'selected': False, 'text': '<p>This may be caused by Visual Studio requiring administrator rights on Windows 7 or higher. To check, see whether the registry key mentioned below is set. If not, copy into a <code>.reg</code> and merge. Be sure to check that your Visual Studio 2005 installation path in the <code>.reg</code> file is correct!</p>\n\n<pre><code>Windows Registry Editor Version 5.00\n\n; Run Visual Studio 2005 with administrator rights\n; This is required to run / debug the program directly from the IDE\n[HKEY_CURRENT_USER\\Software\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers]\n"C:\\\\Program Files (x86)\\\\Microsoft Visual Studio 8\\\\Common7\\\\IDE\\\\devenv.exe"="~ RUNASADMIN"\n</code></pre>\n'}]
['https://Stackoverflow.com/questions/81071', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3181/']