title: C# COM dll has REGDB_E_CLASSNOTREG error in C++ project
body: <p>I have a C# dll that I properly have registered for COM Interop, and made COM visible.  Using cppbuilder, I imported the type library, which generated the wrapper classes, and I am now attempting to use to create an instance of my C# class.  However, I'm getting a REGDB_E_CLASSNOTREG error in my C++ code.  I verified the dll is in the registry, and even re-registered it with regasm.  No change.  What could I be missing?</p>
  
  <p>Here is my C++ code:</p>
  
  <pre><code>_MyClassPtr obj;
  HRESULT hr = obj.CreateInstance(__uuidof(MyClass));
  //now hr equals REGDB_E_CLASSNOTREG
  </code></pre>
  
  <p>I've also tried it as such:</p>
  
  <pre><code>IMyClass* obj;
  HRESULT hr = CoCreateInstance(__uuidof(MyClass), NULL, CLSCTX_INPROC_SERVER, __uuidof(IMyClass), (void**) &amp;obj);
  //same result, hr equals REGDB_E_CLASSNOTREG
  </code></pre>
  
  <p>I do have one additional dependency in the C# app.  I registered it for COM as well with no difference, but did not import it's type library into the C++ project.</p>
  
  <p>UPDATE: based on the comments below, I discovered that CreateInstance is looking up the class guid in the following places in the registry:</p>
  
  <pre><code>HKCU\Software\Classes\Wow6432Node\CLSID\{guid} 
  HKCR\Wow6432Node\CLSID\{guid}
  HKCU\Software\Classes\CLSID\{guid}
  HKCR\CLSID\{guid}
  </code></pre>
  
  <p>But, going through the registry, the only entry under any of the CLSID nodes that is related to my assembly is the guid for the assembly itself, which is, of course, different than the guid for the class, or the interface.</p>
  
  <p>I've manually run regasm under both x86 and x64 mode to try to acheive different results.  No differences.</p>