我用c#开发了一个Windows服务。生成PDF报告。要生成PDF文件,我使用第三方dll。应用程序在我的Windows XP平台上运行。当我在Windows Server 2008 64位版本中部署服务时,我得到了这个错误:

检索的COM类工厂 带有CLSID的组件 {46521 b1f - 0 a5b - 4871 - a4c2 fd5c9276f4c6} 由于以下错误导致失败: 80040154.

我使用regsvr32命令注册了DLL。我能够在注册表中看到这个CLSID。但问题依然存在。

有什么问题吗?


当前回答

如果你正在寻找一种不需要重新编译任何CPU应用程序的方法,这里有另一种潜在的解决方案:

Locate your COM object GUID under the HKey_Classes_Root\Wow6432Node\CLSID\{GUID} Once located add a new REG_SZ (string) Value. Name should be AppID and data should be the same COM object GUID you have just searched for Add a new key under HKey_Classes_Root\Wow6432Node\AppID. The new key should be called the same as the COM object GUID. Under the new key you just added, add a new String Value, and call it DllSurrogate. Leave the value empty. Create a new Key under HKey_Local_Machine\Software\Classes\AppID\ Again the new key should be called the same as the COM object’s GUID. No values are necessary to be added under this key.

这个解决方案不是我的功劳,但它对我们很有效。查看源代码链接获取更多信息和其他评论。

来源:https://techtalk.gfi.com/32bit对象environment/——64位

其他回答

要更改为x86:

为您的解决方案创建一个安装项目。 创建后,转到解决方案资源管理器,右键单击安装项目。 按“配置管理器”。 点击:“Active Solution Platform”组合框,选择新建(如果没有显示x86) 从第一个组合x86中选择,然后按OK。 重建安装项目,然后重建所有项目。

我也遇到过类似的问题。

我需要在64位机器上开发的Web应用程序中使用旧的32位DLL。我将32位DLL注册到windows\sysWOW64文件夹中,使用该文件夹中的regsvr32版本。

对第三方DLL的调用在Visual Studio中的单元测试中正常工作,但在同一台机器上的IIS中托管的Web应用程序中失败,并出现80040154错误。

将应用程序池更改为“启用32位应用程序”解决了该问题。

如果你正在寻找一种不需要重新编译任何CPU应用程序的方法,这里有另一种潜在的解决方案:

Locate your COM object GUID under the HKey_Classes_Root\Wow6432Node\CLSID\{GUID} Once located add a new REG_SZ (string) Value. Name should be AppID and data should be the same COM object GUID you have just searched for Add a new key under HKey_Classes_Root\Wow6432Node\AppID. The new key should be called the same as the COM object GUID. Under the new key you just added, add a new String Value, and call it DllSurrogate. Leave the value empty. Create a new Key under HKey_Local_Machine\Software\Classes\AppID\ Again the new key should be called the same as the COM object’s GUID. No values are necessary to be added under this key.

这个解决方案不是我的功劳,但它对我们很有效。查看源代码链接获取更多信息和其他评论。

来源:https://techtalk.gfi.com/32bit对象environment/——64位

在我个人的情况下,这个问题是固定的搜索类id在Windows的注册表上的开发机器(因为这个问题是抛出在客户端PC)。该操作将被放置到引起问题的COM组件中:我的. net项目中引用的x86库没有为安装程序或更新程序应用程序注册为OCX/COM。

问候

在VS -项目属性-在Build选项卡-平台目标=X86