Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/268.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Com初始化错误0x80040154用c+加载c#Com对象+;节目 我正在处理我的第一个COM项目,它将一个C语言的DLL导入到C++本地代码应用程序中。我们的应用程序基于Microsoft的CSRegFreeCOMServer VS2008示例项目。我们的系统使用-VS2008、.Net3.5、boost 1.4.2和Qt 4.6.2_C#_C++_Com - Fatal编程技术网

Com初始化错误0x80040154用c+加载c#Com对象+;节目 我正在处理我的第一个COM项目,它将一个C语言的DLL导入到C++本地代码应用程序中。我们的应用程序基于Microsoft的CSRegFreeCOMServer VS2008示例项目。我们的系统使用-VS2008、.Net3.5、boost 1.4.2和Qt 4.6.2

Com初始化错误0x80040154用c+加载c#Com对象+;节目 我正在处理我的第一个COM项目,它将一个C语言的DLL导入到C++本地代码应用程序中。我们的应用程序基于Microsoft的CSRegFreeCOMServer VS2008示例项目。我们的系统使用-VS2008、.Net3.5、boost 1.4.2和Qt 4.6.2,c#,c++,com,C#,C++,Com,该应用程序在我们的32位XP开发设备上运行良好。但是,当我们将系统加载到Windows 7-64位系统时。我们无法使com对象初始化。我们不断得到错误0x80040154(我似乎无法确定它的含义) 我们的头文件是- #ifndef ControlComInterface_h__ #define ControlComInterface_h__ #include <string> #include <ole2.h> // OLE2 Definitions // Impo

该应用程序在我们的32位XP开发设备上运行良好。但是,当我们将系统加载到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__
\ifndef controlcointerface\u h__
#定义ControlComInterface\u h__
#包括
#包括//OLE2定义
//.NET组件需要导入mscorlib.tlb
//见:
//  http://msdn.microsoft.com/en-us/library/s5628ssw.aspx
#仅导入“mscorlib.tlb”原始接口\
高级属性前缀(“\u get”、“\u put”、“\u putref”)\
重命名(“ReportEvent”、“InteropServices_ReportEvent”)
使用名称空间mscorlib;
//从CSRegFreeCOMServer导入导出的COM声明
#导入“.\CSRegFreeCOMServer\bin\Release\CSRegFreeCOMServer.tlb”没有命名为\u guids的\u命名空间
使用名称空间std;
类控件接口
{
公众:
ControlComInterface(无效);
~ControlComInterface(无效);
IFieldsPtr spFields;
IPchFilePtr-sppcfilewrapper;
bool CreateInterfaceObject(字符串和错误消息);
};
#endif//ControlComInterface\u h__
简化的类代码是

    #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;
}
#包括“ControlComInterface.h”
#包括
ControlComInterface::ControlComInterface(无效)
{    }
ControlComInterface::~ControlComInterface(无效)
{    }
bool ControlComInterface::CreateInterfaceObject(字符串和错误消息)
{
HRESULT hr=S_正常;
hr=::协同初始化(NULL);
如果(失败(小时))
{
errorMsg=“协同初始化失败,错误:”;
errorMsg.append(boost::lexical_cast(hr));
返回false;
}
errorMsg=“”;
hr=spFields.CreateInstance(uuuidof(Fields));
如果(失败(小时))
{
errorMsg=“IFields::CreateInstance失败w/err:”;
errorMsg.append(boost::lexical_cast(hr));
返回false;
}
返回true;
}
代码失败,调用
spFields.CreateInstance(…)
时出现错误代码0x80040154,该调用仅使用默认构造函数在com对象中创建类的实例


建议?

0x80040154是
REGDB\u E\u CLASSNOTREG
。也就是说,类未注册

COM无法(在注册表中)找到CLSID=
\uuidof(字段)
的类工厂