C# – Error 80040154 (Class not registered exception) when initializing VCProjectEngineObject (Microsoft.VisualStudio.VCProjectEngine.dll)

ccomdllregistrationexception

I'm trying to run this tool in order to convert a Visual C++ project to makefile.
The project I'm trying to convert project is written in VS2008, so I'm using a reference to Microsoft.VisualStudio.VCProjectEngine.dll from version 9.

It fails in this line:

VCProjectEngine vcprojEngine = new VCProjectEngineObject();

With the following exception:

Retrieving the COM class factory for
component with CLSID
{D19A00C4-A7F9-4E14-A5E1-D060B7EB57F3}
failed due to the following error:
80040154 Class not registered
(Exception from HRESULT: 0x80040154
(REGDB_E_CLASSNOTREG)).

When tried to register VCProjectEngine.dll with regsvr32, I got an error that the entry point DllRegisterServer was not found.

Any idea??

Thanks in advance.

Best Answer

There are not many good reasons this would fail, especially the regsvr32 step. Run dumpbin /exports on that dll. If you don't see DllRegisterServer then you've got a corrupt install. It should have more side-effects, you wouldn't be able to build C/C++ projects anymore.

One standard failure mode is running this on a 64-bit operating system. This is 32-bit unmanaged code, you would indeed get the 'class not registered' exception. Project + Properties, Build tab, change Platform Target to x86.