title: "Access to the Registry Key Denied" when building a .NET DLL for COM Interop
body: <p><strong>Objective</strong>: build a <a href="https://stackoverflow.com/questions/20521060/calling-a-net-dll-from-delphi2006-to-show-a-wpf-form">C# DLL with COM interop to be called by Delphi</a> on another environment.</p>
  
  <p><strong>Problem</strong>: Windows is blocking my build, saying that I don't have privileges to edit the registry.</p>
  
  <p>Context:</p>
  
  <ul>
  <li>I'm using Windows 8, Visual Studio 2012, UAC is turned off.</li>
  <li>I'm using RGiesecke's DllExport to annotate with <code>[DllExport]</code> the methods that I want to export as an Dll.</li>
  <li>I'm using <code>[ComVisible(true)]</code> as suggested <a href="https://stackoverflow.com/a/4745433/675577">here</a>.</li>
  <li>My solution platform target is x86</li>
  <li>I edited my solution's  build propertires and checked <code>Build &gt; Output &gt; Register for COM Interop</code></li>
  <li>I edited by <code>AssemblyInfo.cs</code> and enabled <code>[assembly: ComVisible(true)]</code></li>
  <li>I signed my assembly with a strong name</li>
  </ul>
  
  <p>If I run VS2012 not as an admin I get this error: <code>Cannot register assembly 'absolute\path\to\NameOf.dll' access denied. Please make sure you're running the application as administrator. Access to the registry key 'HKEY_CLASSES_ROOT\NameOf.DllClass' is denied</code></p>
  
  <p>Maybe I need to run Visual Studio as an Administrator. However if I run VS2012 as an admin I get this other error (even more random): <code>Cannot register assembly. Could not load file or assembly 'RGiesecke.DllExport.Metadata, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ad5f9f4a55b5020b' or one of its dependencies. The system cannot find the file specified.</code> </p>
  
  <p>I followed the steps of <a href="http://support.microsoft.com/kb/327507" rel="noreferrer">FIX: "Access to the Registry Key Denied" Error Message When You Register .NET Assembly for COM Interop</a>, namely locating and changing the permissions for <code>HKEY_CLASSES_ROOT\Component Categories\{62C8FE65-4EBB-45e7-B440-6E39B2CDBF29}</code>. No luck.</p>
  
  <p><strong>How can I get the privileges needed to build my DLL and get my <code>tlb</code> file?</strong></p>