2

I'm working on my first COM project that is importing a c# DLL with a C# COM Wrapper class into a C++ native code application. Our application is based on the CSRegFreeCOMServer VS2008 sample project from Microsoft's All-In-One Framework. Our system is using - VS2008, .Net3.5, boost 1.4.2 and Qt 4.6.2.

This application has been running fine on our 32bit XP dev boxes. However, when we load the system onto our Windows 7-64bit system. We cannot get the com objects to initialize. We keep getting error 0x80040154 (which I cannot seem to determine what it means).

Our header file is -

#ifndef ControlComInterface_h__
#define ControlComInterface_h__
#include <string>
#include <ole2.h>    // OLE2 Definitions
// Importing mscorlib.tlb is necessary for .NET components
// see: 
//  http://msdn.microsoft.com/en-us/library/s5628ssw.aspx
#import "mscorlib.tlb" raw_interfaces_only                \
    high_property_prefixes("_get","_put","_putref")        \
    rename("ReportEvent", "InteropServices_ReportEvent")
using namespace mscorlib;
// import the COM Declarations exported com the CSRegFreeCOMServer
#import "..\CSRegFreeCOMServer\bin\Release\CSRegFreeCOMServer.tlb"  no_namespace named_guids
using namespace std;
class ControlComInterface
{
public:
    ControlComInterface(void);
    ~ControlComInterface(void);
    IFieldsPtr spFields;
    IPchFilePtr spPchFileWrapper;
    bool CreateInterfaceObjects(string &errorMsg);
};
#endif // ControlComInterface_h__

The simplified class code is

    #include "ControlComInterface.h"
#include <boost/lexical_cast.hpp>
ControlComInterface::ControlComInterface(void)
    {    }
ControlComInterface::~ControlComInterface(void)
    {    }
bool ControlComInterface::CreateInterfaceObjects( string &errorMsg )
{
HRESULT hr = S_OK;
hr = ::CoInitialize(NULL);  
if (FAILED(hr))
{
    errorMsg = "CoInitialize failed w/err: ";
    errorMsg.append(boost::lexical_cast<string>(hr));
    return false;
    }
errorMsg = "";
hr = spFields.CreateInstance(__uuidof(Fields));
if (FAILED(hr))
    {
    errorMsg = "IFields::CreateInstance failed w/err: ";
    errorMsg.append(boost::lexical_cast<string>(hr));
    return false;
    }
return true;
}

The code is failing with a error code of 0x80040154 on the call to spFields.CreateInstance(...), which just creates an instance of the class in the com object using a default constructor.

Suggestions?

1 Answer 1

2

0x80040154 is REGDB_E_CLASSNOTREG. That is, class not registered.

The COM couldn't find (in the registry) the class factory with CLSID = __uuidof(Fields).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.