3

I´m trying to run COM.Scanner project but the follow exception is thrown:

Retrieving the COM class factory for component with CLSID {9F8D4F16-0F61-4A38-98B3-1F6F80F11C87} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).

Like Interop.CoreScanner is a .NET assembly I use regasm to register the COM objects, but the error still occurs.

I come to read this good post but none of answers solved the problem.

This the information of Corflags:

Microsoft (R) .NET Framework CorFlags Conversion Tool.  Version  4.6.81.0
Copyright (c) Microsoft Corporation.  All rights reserved.

Version   : v2.0.50727
CLR Header: 2.5
PE        : PE32
CorFlags  : 0x1
ILONLY    : 1
32BITREQ  : 0
32BITPREF : 0
Signed    : 0

The generated .reg file with regasm and /regfile option is:

REGEDIT4

[HKEY_CLASSES_ROOT\CLSID\{9F8D4F16-0F61-4A38-98B3-1F6F80F11C87}\InprocServer32]
"Class"="CoreScanner.CCoreScannerClass"
"Assembly"="Interop.CoreScanner, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
"RuntimeVersion"="v2.0.50727"
"CodeBase"="file:///D:/Github/miscelaneas/COM.Scanner/libs/Interop.CoreScanner.dll"

[HKEY_CLASSES_ROOT\CLSID\{9F8D4F16-0F61-4A38-98B3-1F6F80F11C87}\InprocServer32\1.0.0.0]
"Class"="CoreScanner.CCoreScannerClass"
"Assembly"="Interop.CoreScanner, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
"RuntimeVersion"="v2.0.50727"
"CodeBase"="file:///D:/Github/miscelaneas/COM.Scanner/libs/Interop.CoreScanner.dll"

Environment:

  • OS: Windows 10 (x64)
  • Visual Studio 2015

QUESTION

  • This smells like that there are missing entries on registry, but I don´t know which.
  • If I´m in the right way why regasm is not able to generate the missing registry entries?
Community
  • 1
  • 1
Jose Rodriguez
  • 9,753
  • 13
  • 36
  • 52
  • 3
    Never, *never*, **never** register an interop library. You must register the native COM component instead, using Regsvr32.exe or (preferably) the vendor's installer. If you don't have that installer then use a telephone, looks like you need to call Zebra. If you did have it then your use of Regasm.exe destroyed the install, you'll have to re-install. – Hans Passant Jul 18 '16 at 19:23
  • If I don´t want as requirements to the clients install a SDK I need a native COM component and register it with Regsvr32.exe? – Jose Rodriguez Jul 18 '16 at 19:40
  • Again, use a telephone to talk to the vendor and ask for specific install advice. Asking for a merge module that you can integrate with your own installer is best. – Hans Passant Jul 18 '16 at 19:45
  • Obviously my knowledge about COM is not of most advanced, then any final consumer of native component let say on X language need a compiled Interop library on X?, that works as a bridge? Since I published the question had great faith in you were going to clarify the doubts @Hans. Grateful. – Jose Rodriguez Jul 18 '16 at 19:52
  • I recently ran into this exact same problem. It required me finding a machine which the program ran successfully, then checking the registry for the key and running regsvr32.exe on it: [http://stackoverflow.com/questions/7197506/how-to-repair-comexception-error-80040154] – Matthew Alltop Jul 18 '16 at 20:03

1 Answers1

3

It seems that the missing component is installed together with Motorolas EMDK SDK. Installing the SDK should solve your issue.

Registering the interop assembly does not take you any further, as the interop assembly is just a library containing the type definitions of the COM component so that you are able to compile your C# code with static typing and early binding. The actual thing that needs to be registered is the underlying COM component. To register that you would use regasm.exe only if the actual COM component if the COM component was written in .NET. Otherwise you need to use the classic regsvr32.exe (or use the installer of the component vendor).

Dirk Vollmar
  • 172,527
  • 53
  • 255
  • 316
  • 1
    I solved with that link. Also installing the Scanner SDK [here](https://www.zebra.com/us/en/products/software/scanning-systems/scanner-drivers-and-utilities/scanner-sdk-for-windows.html) solve the problem. – Jose Rodriguez Jul 18 '16 at 20:41