mfc >> OLE/COM Class "Class not registered" error

by Bjn Marthen » Wed, 23 Nov 2005 18:11:20 GMT


i added to my dialog-based application an automation server. I used the
article on and via late
binding it seems to work fine (VBS test). But when i want to write a
client in c++ (early binding) then CoCreateInstance return the error
"class not registered".

The error seems to be in my server-application. In the "OLE/COM Object
Viewer" the TypeLib seems to be installed correct.

i register the server with the following code in InitInstance() via:
------ snip ------
CCommandLineInfo cmdInfo;
if (cmdInfo.m_bRunEmbedded || cmdInfo.m_bRunAutomated)
return TRUE;
else if (cmdInfo.m_nShellCommand == CCommandLineInfo::AppUnregister)
return FALSE;
bool updated = COleObjectFactory::UpdateRegistryAll();
bool registered = AfxOleRegisterTypeLib(AfxGetInstanceHandle(),
if (cmdInfo.m_nShellCommand == CCommandLineInfo::AppRegister)
return FALSE;
if (!ProcessShellCommand(cmdInfo))
return FALSE;
------ /snip ------

Where can be the failure? The demo application from the article works fine.

regards, Bjn

mfc >> OLE/COM Class "Class not registered" error

by Headache » Wed, 23 Nov 2005 20:01:39 GMT

Well is it registered? Using the same article you would need to do the
following steps:

The CoClass from the IDL and IMPLEMENT_OLECREATE must match as they do
in the example:

[ uuid(9ACC7108-9C10-4A49-A506-0720E0AACE32) ]
coclass Application

IMPLEMENT_OLECREATE(CApplication, "mycoolapp.Application",
0x9acc7108, 0x9c10, 0x4a49, 0xa5, 0x6, 0x7, 0x20, 0xe0, 0xaa, 0xce,

Do the two match?

Next check for the CLSID key under HKEY_CLASSES_ROOT\CLSID does it
exist? No? Then the class isn't registered you will have to step into
your code and find out why? Perhaps the registration information is
held in a resource script (.res) and you haven't updated the CLSID

mfc >> OLE/COM Class "Class not registered" error

by Bjn Marthen » Wed, 23 Nov 2005 20:20:49 GMT


You saved my life!!! That was the failure.

Many thanks and regards, Bjn

Similar Threads

1. COM Components: class not registered error in CE .NET


I have an ATL COM Component. It registers on my device using regsvrce
and on the CE .NET emulator using EVC4.
regsvrce runs fine and gives me a Component registered successfully message.

When i try to load my COM component using CoCreateInstance, it returns a
class not registered error.

I do it like this:
    CComPtr<IMyObj> pObj;
    hr = pObj.CoCreateInstance(CLSID_MyObj);

If i try to load an MS COM Component included in the device or emulator,
such as XMLDOMDocument, the call succeeds.
    CComPtr<IXMLDOMDocument2> pObj;
    hr = pObj.CoCreateInstance(CLSID_XMLDOMDocument);

How can i successfully register and load my own COM components under CE
It's a project critical need.

Louis-Pierre Beaumont
VER-MAC inc.

2. Help C++.Net2003 {0x80040154 Class not registered } Com Interop

3. dllregisterserver not registering com classes

I have a COM DLL (created with the ATL COM wizard). It comes with the

// DllRegisterServer - Adds entries to the system registry
STDAPI DllRegisterServer(void)
    // registers object, typelib and all interfaces in typelib
    HRESULT hr = _AtlModule.DllRegisterServer();
    return hr;

This function does get called when the object is registered, but none
of the interfaces I have defined get registered.
Do I need to put code in to manually register my objects? What does
that function register, then?


4. Crystal Report - Error "class not registered" - CSharp/C#

5. DTS Package Class Not Registered Error From C++ Application

Hello. I have a Windows service written in C++ that imports a text file
to a SQL 2000 SP3 database using a DTS package. It has been running
fine on a Windows 2000 machine. We recently configured a new server
running Windows Server 2003 and SQL 2000 SP3 and now the service gets
the error 80040154 (Class Not Registered) when it trys to instantiate
the DTS object:

ppkgDTS.CreateInstance( __uuidof( DTS::Package ) );

I have re-registered the following dll's on the new server and the
problem still occurs:

dtsffile.dll, dtspkg.dll, dtspump.dll, axscphst.dll, custtask.dll

And I've made sure that the following files are in the correct folders:

sqlresld.dll, dtsffile.rll, dtspkg.rll, dtspump.rll, axscphst.rll,
dtsrun.rll, custtask.rll, sqlunirl.dll

I'm able to run the DTS package manually through Enterprise Manager
with no problems. One difference in the server configurations is that
the W2K server has MDAC 2.6 installed and the W2K3 server has MDAC 2.8.
I'm not sure how to (or if I want to) rollback the W2K3 server to
version 2.6 to see if this is the problem. Any help or ideas would be
greatly appreciated.


6. CoCreateInstance and "Class not registered" error...

7. CoCreateInstance gives Class not registered error

Platform: VC++ (.NET),Windows 2000


I have implemented persistence storage using IStorage and IStream in my
I am serializing some COM objects in these streams.

The library that has implemented this registers these objects.

However when I call the CoCreateInstance for the object, it fails giving the
error [-2147221164] [Class not registered].

Could someone let me know, why am I facing this problem? I can see the class
registered in the registry.
Do I need to make any more entries in the registry in order to make the code
work properly?

Thanks and Regards

This is my code for registering the COM objects
STDAPI DllRegisterServer(void)
 szID =  "{3A87C0C1-6DC0-11d3-9DF8-004033E0CAF6}";
 szProgID = "MY.IDXWRAP.1";

 // Creating the key and setting the values
 // First create the progid entry in the root
  return S_FALSE;

This is the code for loading the file.
CObject* CSerialize::LoadObject(const CString& strFileName)
IStorage* pStg;
 COleVariant vstrFileName(strFileName);
 HRESULT h = StgOpenStorage(vstrFileName.bstrVal,       NULL,

HRESULT h1 = CoCreateInstance(statstg.clsid,
      NULL,     CLSCTX_ALL,      IID_IPersistStream,
(void**)&pPersistStm);//It FAILs here

8. Class registered but interface is not registered