2
votes

I have developed a sample c# COM-Visible DLL.
Built in x86 and registered via 32-bit Regasm, it executes well by COM Client.
Built in x64 and registered via 64-bit Regasm, the COM Client call drops the following error :

Retrieving the COM class factory for component with CLSID {A0F2F58F-7B98-3605-BEC9-84724FF1E824} failed due to the following error: 80040154.

I checked and made sure that CLSID is present indeed in the registry under HKCR\CLSID.

Below is an example of simulating a COM Access via c# :

var type = Type.GetTypeFromProgID("ProgID.Interop.5683");
var obj = Activator.CreateInstance(type); // <-- blows here

I also checked via procmon that there is a successful access to the type via progId The question is, where is the Activator looking exactly ? and how to make it "see" my x64 registered assembly ? is there something I need to add somewhere ?

I have found many "solutions" advising an x86 re-build. But Come'on ! I am not going to do that and lose all x64 benefits just for COM's sake. Is there a "REAL" solution to that ?

1
In what situations is the 80040154 error thrown? - Security Hound
@Ramhound When the CLSID is not there or not at the right expected place. So i'm very confused. - Mehdi LAMRANI
You don't build a managed DLL for a particular architecture, only the setting of the EXE project matters. Classic mistakes are using the wrong bitness of Regasm.exe or forgetting the /codebase option. Troubleshoot with SysInternals' ProcMon utility. - Hans Passant
@HansPassant I used both flavours of Regasm for x64 (V2 & V4) alternatively taking care to unregister between attemps and I did use /codebase wich, and As states, I also used procmon for monitoring - Mehdi LAMRANI
Time to do some registry diving. Go to HKEY_CLASSES_ROOT\CLSID. You should find a key under there for {A0F2F58F-7B98-3605-BEC9-84724FF1E824}. Under that key you are going to find your info for where the assembly is for the object in and under the InprocServer32 key. Note that this will be for tbe x64 object on the x64 system. - user957902

1 Answers

0
votes

After a night of sleep and a little hindsight, I figured out that the Activator needed to be called from an x64 App, to find the x64 CLSID by looking in the x64 locations in the Registry. i.e, when called from an x86 App, Activaor looks in the x86 locations in the Registry for CLSID and subsequent key including codebase.

var type = Type.GetTypeFromProgID("ProgID.Interop.5683");
var obj = Activator.CreateInstance(type);