title: COM exception in x64 : Retrieving the COM class factory for component with CLSID {} failed due to the following error: 80080005
body: <p>I have a C++ 'App1' which was previously built in win32 but is now upgraded to work in x64. The App1 has .tlb files which I used to create COM interop dlls. Previously they used to be registered as win32 but now are registered as win64. The interop dlls are referenced in a c# application 'App2', this app used to be built in AnyCPU platform, but I've changed it to x64.</p>
  <p>Here's the code in App2 when it accesses the COM objects;</p>
  <pre><code> objClassType = Type.GetTypeFromProgID(&quot;App1COM.App1Application&quot;);  
  
   if (objClassType != null)
   {
        objApp_Late = Activator.CreateInstance(objClassType); //gets stuck in this place for ages then is thrown an exception
        radCmApp = (App1COM.AppApplication)objApp_Late;
        radCmApp.Visible = true;
   }
  </code></pre>
  <p>The exception is as follows;</p>
  <blockquote>
  <p>Retrieving the COM class factory for component with CLSID
  {4B3D644C-6FC0-4805-9448-E98245F2CE89} failed due to the following
  error: 80080005. at</p>
  <p>System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean
  publicOnly, Boolean noCheck, Boolean&amp; canBeCached,
  RuntimeMethodHandle&amp; ctor, Boolean&amp; bNeedSecurityCheck) at</p>
  <p>System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean
  fillCache) at</p>
  <p>System.RuntimeType.CreateInstanceImpl(Boolean
  publicOnly, Boolean skipVisibilityChecks, Boolean fillCache) at</p>
  <p>System.Activator.CreateInstance(Type type, Boolean nonPublic)</p>
  </blockquote>
  <p>An instance of App1 does get created, as seen in the Task Manager, but it closes as soon as App2 hits the exception. I debugged this instance of App1 but could not find how the exception occurs, to me it seems like the exception occurs regardless where the debugger is in App1, and at a timed interval. I'm wondering if this is some internal COM issue. I get the same error if I change App2 configuration to AnyCPU.</p>
  <p>The x64 App1 works perfectly if I run it independently. The COM link worked when App1 was in win32 and App2 was in AnyCPU/x86, now with x86 I get:</p>
  <blockquote>
  <p>&quot;Could not load file or assembly 'Interop.App1COM, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.&quot;</p>
  </blockquote>
  <p>...which is why I switched App2 to x64.</p>
  <p>Any help would be appreciated.</p>
  <p>Edit -
  Adding a pic of the App1 Document (Radial Document) as seen in the Oleviewer.exe (Grouped by Component Category\All Objects)
  <a href="https://i.stack.imgur.com/u58wx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/u58wx.png" alt="enter image description here" /></a></p>