0
votes

I am trying to create the com object using following code:

Type testlib = Type.GetTypeFromProgID("TestComApp.TestApp.TestClass");
dynamic comObj = Activator.CreateInstance(testlib);

But getting the error :

An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in mscorlib.dll

Additional information: Retrieving the COM class factory for component with CLSID {FD909333-3CD0-477F-8A7E-B8045B0B84EC} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154REGDB_E_CLASSNOTREG)).

I have tried building the project with AnyPlatform ,X86, x64 bit platform and the used RegAsm for 32 and 64bit .

But still not able to get it working. I have verified in registry and the class and CLSID with GUID exists

enter image description here

2
Use SysInternals' Process Monitor. Use it when you run Regasm.exe, you can see exactly what registry keys are being written. And use it when you run your client app, you can see exactly what keys are being read. The discrepancy you see gives you a strong lead towards the underlying issue. - Hans Passant
The ProgId is just one part of the registration. What do you have in HKCR\CLSID? - acelent

2 Answers

0
votes

It Started working , once I use codebase with Regasm

cd "C:\Windows\Microsoft.NET\Framework\v4.0.30319"

regasm /codebase C:\DATA\TestComApp\TestComApp\bin\Debug\TestComApp.DLL

Earlier I was doing :

cd "C:\Windows\Microsoft.NET\Framework\v4.0.30319"

regasm C:\DATA\TestComApp\TestComApp\bin\Debug\TestComApp.DLL
0
votes

I had the same problem in a WCF project in production mode (in IIS). In development mode (Visual Studio) the error does not occur.

For me, the solution was in IIS -> Application Pool -> Advanced Settings -> Enable 32-Bit Applications: enter image description here