Search code examples
c#.netasp.net-corecom

Using COM Object in .NET Core 2.0


So, a client has a COM object written in C from 2007 that validates an encrypted session cookie. This currently works fine with older versions of .NET using the following.

var validate = Activator.CreateInstance(Type.GetTypeFromProgID("Company.Validate"));

The new implementation will be entirely in C#. I've extracted validation logic to a .NETCore class library, which we in turn reference in our ASP.Net Core project.

  1. I've tried 32-bit & 64-bit versions, as well as IIS settings.

  2. I've decompiled the COM object and referenced that instead, it works locally, but not on the development server, where I receive the following error:

    Retrieving the COM class factory for component with CLSID {EDC43BC6-5ECD-4501-AEB3-64A17180A13D} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).

  3. The COM is registered both locally and on the development server.

  4. Activator.CreateInstance does not work in either environment.

  5. The registered COM ID and ProgId is the same both locally and on the development server.


Q: What am I missing, or is this not going to work? Has anyone had any success with similar challenges? Am I overlooking anything?


Solution

  • The required registry keys were never created. I had to manually add about 15 keys, for the Class, Interface, and Type. I believe this is because the COM had never been marshaled or invoked (because that wouldn’t work) so the Class ID, AppID and registry mapping’s had to be entered manually.