2010-08-23 5 views
1

C# COM 래퍼 클래스가있는 C# DLL을 C++ 원시 코드 응용 프로그램으로 가져 오는 첫 번째 COM 프로젝트에서 작업하고 있습니다. 우리의 응용 프로그램은 Microsoft의 All-In-One Framework의 CSRegFreeCOMServer VS2008 샘플 프로젝트를 기반으로합니다. 우리 시스템은 - VS2008, .Net3.5, 부스트 1.4.2 및 Qt 4.6.2를 사용합니다.Com 초기화 오류 0x80040154 C++ COM + 개체를 C++ 프로그램으로로드 중

이 응용 프로그램은 32 비트 XP dev 박스에서 잘 돌아갑니다. 그러나 Windows 7-64 비트 시스템에 시스템을로드 할 때. 우리는 com 객체를 초기화 할 수 없습니다. 우리는 0x80040154 오류가 계속 발생합니다 (어떤 의미인지는 알 수 없습니다).

우리의 헤더 파일입니다 -

#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__ 

단순화 된 클래스 코드는 코드는 단지의 인스턴스를 생성 spFields.CreateInstance(...)에 대한 호출에 0x80040154의 오류 코드와 함께 실패

#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; 
} 

입니다 com 객체의 클래스는 기본 생성자를 사용합니다.

제안 사항?

답변

1

0x80040154는 REGDB_E_CLASSNOTREG입니다. 즉, 클래스가 등록되지 않았습니다.

COM에서 CLSID = __uuidof(Fields) 인 클래스 팩토리를 찾을 수 없습니다 (레지스트리에서).