Search code examples
c#cominteropcom-interop

Exception when creating COM-Object


I have referenced an Interop-Assembly, which I have created with tlbimp.exe. Now, when I create a object of a class from this Interop-Assembly like

var allplanInstance = new AllplApplicationClass();

This is working on my machine and some customer machines. But on some other Customer-Machines, I will get the following Exception:

System.Runtime.InteropServices.COMException (0x80004005): 
Creating an instance of the COM component with CLSID {D8CFBF83-AFC7-11D2-A4F4-0000D1106F9C} from the IClassFactory failed due to the following error: 80004005.

I have checked if the CLASS-ID {D8CFBF83-AFC7-11D2-A4F4-0000D1106F9C} is registered in the Registry - this is the case on all machines.

What can I do to find the reason of this problem?

Thanks for your hints.


Solution

  • One common reason this happens is when deploying these types of applications to 64 bit machines. If the machine is 64 bit you have to build the calling C# application in x86. In addition to this the COM dll has to be registered using the 32 bit version of regsvr32.exe which is in the Windows/SysWow64/ folder.