COMException when instantiating class from a DLL

1

I am new to .NET and windows in general (but have experience with C/C++) and am running into a problem when I try to instantiate a class that is defined in a dll.

MY SETUP:

In Visual Studio 2013, my solution contains two projects:

  1. c# windows application (.NET 4.5)
  2. a c++ dll (inherited from older code) - call it dllLib.dll

As a pre-build step for the c# application, I generate a COM interop from the dll using tlbimp. This gives me interop.dllLib.dll, which I add as a reference in the c# project.

When I try to instantiate a dll class (called switchboard) from the c# project, I get the following error:

dllLib.switchboard myclass = new dllLib.switchboard();

An exception of type 'System.Runtime.InteropServices.COMException' occurred in mscorlib.dll but was not handled in user code Additional information: Retrieving the COM class factory for component with CLSID {D7EBBF24-5620-4AED-871B-2027471FD075} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).

I am stumped. The dll registers without a problem (regsvr32 works). The c# app can see the Interface for the class "switchboard", and it compiles without complaint.

THINGS I HAVE ALREADY TRIED/CHECKED:

  • Running Visual Studio as administrator

  • Active Solution is Debug x86

  • Project contexts are x86(c#) and Win32(dll)

  • regsvr32 /n /i:user dllLib.dll is successful, but interestingly, unregistering it with /u fails.

Error message on unregistering dll:

The call to DllUnregisterServer failed with error code 0x8002801c

Any suggestions you can offer on what to try or troubleshoot are greatly appreciated.

c#
.net
dll
asked on Stack Overflow Apr 21, 2016 by Louie • edited Apr 21, 2016 by VVN

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0