title: Class not registered error when trying to use COM (even from 32 bit process)
body: <p>I need to use a 3rd party COM library to interact with an API. It seems to have installed ok, and there is a test harness that has been provided to me that seems to work OK, so I'm sure there's nothing wrong with the DLL.</p>
  
  <p>My .NET code looks like this (in vs 2015):</p>
  
  <pre><code>Type t = Type.GetTypeFromCLSID(new Guid("xxxxx")); //this works ok
  object o = Activator.CreateInstance(t); // this throws an error
  </code></pre>
  
  <p>The error thrown is: </p>
  
  <pre><code>An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in mscorlib.dll
  Additional information: `Retrieving the COM class factory for component with CLSID {xxxxx} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).`
  </code></pre>
  
  <p>I have ensured all projects including the main one are x86 (as I know the DLL is a 32 bit lib):</p>
  
  <p><a href="https://i.stack.imgur.com/aWFA1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aWFA1.png" alt="32 bit"></a></p>
  
  <p>For good measure, I tried to re-register the lib like this: <code>Regsvr32 xxxx.dll /s</code> but still getting the same error.</p>
  
  <p>Any help would be great! Thanks.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>The main project is indeed set to x86, "prefer 32 bit" is therefore greyed out.</p>
  
  <p><a href="https://i.stack.imgur.com/32V3O.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/32V3O.png" alt="enter image description here"></a></p>