1

I am trying to upgrade an old asmx webservice to Web API. Idealy I would like to use .Net Core as that is what we have been developing in. The issue is that the API must communicate with a legacy system using a COM object.

I have copied over the dll (already not ideal, I know) and, the .Net Core API project is able to add it as a reference and the code all compiles. However, on running the code I get the following error when instantiating an object from the dll:

Retrieving the COM class factory for component with CLSID 
{CCA0B90B-DFDE-4DD3-9C7B-9769A3F12201} failed due to the following error: 
80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)). 

I've tried to do exactly the same thing using the full .Net framework and everything works as expected so I imagine it is an issue with Core - maybe the portability requirements.

It will not be possible to rewrite the integration to the legacy system at this point and I was just wondering if there was any way around this without using the full .Net framework.

Update

I don't know if this will help but I can created a .Net Framework console app which runs the code just fine. when I reference the project from my .Net Core API and call the exact same code the error above still occurs.

SBFrancies
  • 3,987
  • 2
  • 14
  • 37
  • I would take a look at Matt Johnson's answer to the following question (https://stackoverflow.com/a/46866309/1143474) as a starting point. Also take a look through the question that Matt is answering and check whether it applies to your specific use case. – Jamie Taylor Jan 09 '18 at 13:40
  • I've had a look at that and unfortunately it results in exactly the same error. – SBFrancies Jan 09 '18 at 13:50
  • I would probably say that .NET Core isn't the way to go for COM stuff, then. Could you not create a .NET Standard library which calls the COM object you need, and consume the .NET Standard library within your application? – Jamie Taylor Jan 09 '18 at 14:17
  • Oddly, that also causes the same error. Maybe it has to do with the runtime environment. – SBFrancies Jan 09 '18 at 15:04
  • What is the Platform Target of the .NetFramework console app you created, where it works? – byte Jan 09 '18 at 16:48
  • .Net Framework 4.6.1, Any CPU - Prefer 32-bit. – SBFrancies Jan 10 '18 at 08:27
  • Microsoft provides tools that will help with such migration work last autumn. Please try [Windows Compatibility Pack for .NET Core](https://blogs.msdn.microsoft.com/dotnet/2017/11/16/announcing-the-windows-compatibility-pack-for-net-core/) and [API Analyzer](https://blogs.msdn.microsoft.com/dotnet/2017/10/31/introducing-api-analyzer/). However, according to the blog, it is possible to access the registry with the Compatibility Pack, but the COM related function (System.ComponentModel.Composition) seems to be working. – kunif Jan 11 '18 at 13:29

0 Answers0