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.
Here's the code in App2 when it accesses the COM objects;
objClassType = Type.GetTypeFromProgID("App1COM.App1Application");
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;
}
The exception is as follows;
Retrieving the COM class factory for component with CLSID {4B3D644C-6FC0-4805-9448-E98245F2CE89} failed due to the following error: 80080005. at
System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck) at
System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean fillCache) at
System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean fillCache) at
System.Activator.CreateInstance(Type type, Boolean nonPublic)
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.
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:
"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."
...which is why I switched App2 to x64.
Any help would be appreciated.
Edit -
Adding a pic of the App1 Document (Radial Document) as seen in the Oleviewer.exe (Grouped by Component Category\All Objects)