title: Setting up a DLL for registration-free COM Interop with C# / Managed code
body: <p>I am new to COM and have to create a COM wrapper for a C++ dll, to make some functionality in it accessible for managed code.  I mainly followed <a href="http://www.codeproject.com/Articles/8745/A-Beginner-tutorial-for-writing-simple-COM-ATL-DLL" rel="nofollow">this tutorial on code project</a> to create a COM ATL dll. I created a post-build-step that calls tlbimp.exe on the COM dll to create the wrapping. </p>
  
  <p>Adding a reference to the dll that tlbimp.exe creates works, and I get code completion for methods on my COM dll, and can compile managed code that uses that dll. However, running that code leads to the following exception: </p>
  
  <pre><code>Unhandled Exception: System.Runtime.InteropServices.COMException: Retrieving the COM class factory 
  for component with CLSID {FD6F73D2-0208-455A-953A-C911EC2CAEAB} failed due to the following error: 
  80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
  //...
  </code></pre>
  
  <p>If I understand this exception and the documentation on MSDN correctly, the next step would be to set up the 'registration-free' part of registration-free COM interop. I have looked at various guides such as <a href="http://msdn.microsoft.com/en-us/library/ms973913.aspx" rel="nofollow">this one</a> and <a href="http://msdn.microsoft.com/en-us/library/fh1h056h%28v=vs.110%29.aspx" rel="nofollow">this one</a>, but I still don't understand what I have to do. </p>
  
  <p>So my question is: </p>
  
  <p>What are the basic steps I need to take to make my newly created .Net-compatible COM dll load without registration? </p>
  
  <p>Do I have to write a manifest for my .Net app that uses the COM dll?
  Do I have to write a manifest for my COM dll? Or the DLL that tblimp.exe generates from it? </p>