Class not registered ... when trying to call a managed C # library from unmanaged C ++

I have a C # library that I am using for a COM object in unmanaged C ++ code. I registered the library using the Visual Studio "Register For Com Interop" checkbox and set ComVisible to true.

imported tlb into c ++ app ..... when i run it i get "class not registered" ....

This worked before, but it started after I moved my C # project directory to a different location .... yes, I re-registered the library after I moved it.

I removed all references from the registry ... I even tried to do gacutil.exe / i on it ... boneless.

Does anyone know how to fix this?

+2


source to share


2 answers


If you do not have an explicit CLSID set on the managed object, it is possible that the move and rebuild created a new CLSID. Make sure your unmanaged project does not have an outdated copy of typelib.



Go to HKCR \ CLSID \ {XXXX} and verify that the class registration for the managed object points to the correct managed DLL.

0


source


The best way to use unmanaged objects in managed code is to use C ++ / CLI. You can easily create a controlled wrapper around your own object.



0


source







All Articles