title: Embedding unmanaged dll into a managed C# dll
body: <p>I have a managed C# dll that uses an unmanaged C++ dll using DLLImport. All is working great.
  However, I want to embed that unmanaged DLL inside my managed DLL as explain by Microsoft there:</p>
  
  <p><a href="http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.dllimportattribute.dllimportattribute.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.dllimportattribute.dllimportattribute.aspx</a></p>
  
  <p>So I added the unmanaged dll file to my managed dll project, set the property to 'Embedded Resource' and modify the DLLImport to something like:</p>
  
  <pre><code>[DllImport("Unmanaged Driver.dll, Wrapper Engine, Version=1.0.0.0,
  Culture=neutral, PublicKeyToken=null",
  CallingConvention = CallingConvention.Winapi)]
  </code></pre>
  
  <p>where 
  'Wrapper Engine' is the assembly name of my managed DLL
  'Unmanaged Driver.dll' is the unmanaged DLL</p>
  
  <p>When I run, I get:</p>
  
  <blockquote>
    <p>Access is denied. (Exception from HRESULT: 0x80070005
    (E_ACCESSDENIED))</p>
  </blockquote>
  
  <p>I saw from MSDN and from <a href="http://blogs.msdn.com/suzcook/" rel="noreferrer">http://blogs.msdn.com/suzcook/</a> that's supposed to be possible...</p>