由于以下错误,检索 CLSID {XXXX} 的组件的 COM 类工厂失败:80040154
我使用 C#.NET 开发了一个 Windows 服务来生成 PDF 报告。 为了生成 PDF 文件,我使用第三方 dll。 该应用程序正在我的 Windows XP 平台上运行。 当我在 Windows Server 2008 64 位版本中部署服务时,出现以下错误:
检索 COM 类工厂 具有 CLSID 的组件 {46521B1F-0A5B-4871-A4C2-FD5C9276F4C6} 由于以下错误而失败: 80040154。
我使用regsvr32命令注册了DLL。 我能够在注册表中看到这个 CLSID。 但问题仍然存在。
可能是什么问题呢?
I developed a Windows service using C#.NET to generate PDF report. To generate PDF file I am using a third party dll. The application is running in my Windows XP platform. When I deployed the service in Windows Server 2008 64 bit version, I got this error:
Retrieving the COM class factory for
component with CLSID
{46521B1F-0A5B-4871-A4C2-FD5C9276F4C6}
failed due to the following error:
80040154.
I registered the DLL using the regsvr32 command. I able to see this CLSID in the registry. But the problem persists.
What could be the problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(18)
在VS中-项目属性-在构建选项卡中-平台目标=X86
In VS - project properties - in the Build tab - platform target =X86
我遇到了一个非常相似的问题。
我需要在 64 位计算机上开发的 Web 应用程序中使用旧的 32 位 DLL。 我使用该文件夹中的 regsvr32 版本将 32 位 DLL 注册到 windows\sysWOW64 文件夹中。
对第三方 DLL 的调用可以在 Visual Studio 中的单元测试中进行,但在同一台计算机上的 IIS 中托管的 Web 应用程序中失败,并出现 80040154 错误。
将应用程序池更改为“启用 32 位应用程序”解决了该问题。
I ran into a very similar issue.
I needed to use an old 32-bit DLL within a Web Application that was being developed on a 64-bit machine. I registered the 32-bit DLL into the windows\sysWOW64 folder using the version of regsvr32 in that folder.
Calls to the third party DLL worked from unit tests in Visual Studio but failed from the Web Application hosted in IIS on the same machine with the 80040154 error.
Changing the application pool to "Enable 32-Bit Applications" resolved the issue.
听起来您的服务是针对“任何 CPU”构建的,导致您在使用 COM 组件的 64 位上出错。 您需要为
x86
构建它。该网站可能作为 32 位进程运行,这就是它可以使用该组件的原因。 针对
x86
构建解决方案将强制您的服务以 32 位运行。It sounds like your service was built against 'Any CPU', causing you errors on 64-bit where you are using COM components. You need to build it for
x86
.The website is probably running as a 32-bit process which is why it can use the component. Building your solution against
x86
will force your service to run as 32-bit.如果您正在寻找一种无需重新编译 Any CPU 应用程序即可完成此操作的方法,这里有另一个潜在的解决方法:
同样,新密钥的调用方式应与 COM 对象的 GUID 相同。 无需在该键下添加任何值。
我不相信这个解决方案,但它对我们有用。 检查源链接以获取更多信息和其他评论。
来源:https://techtalk.gfi.com/32bit-object-64bit-environment/
If you are looking for a way to make this work without recompiling your Any CPU application, here is another potential workaround:
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.
I take no credit for the solution, but it worked for us. Check the source link for more information and other comments.
Source: https://techtalk.gfi.com/32bit-object-64bit-environment/
您不必配置项目属性平台目标 X86。
您还可以配置 iis 选项以与 x86 一起使用,如下所示
You dont have to configure your project properties platform target X86.
You can also configure the iis options to work with x86 like that
问题是服务器进程是 64 位,而库是 32 位,并且它尝试在同一进程(进程内服务器)中创建 COM 组件。 要么重新编译服务器并将其设置为 32 位,要么保持服务器不变并将 COM 组件设置为进程外。 使 COM 服务器脱离进程的最简单方法是创建 COM+ 应用程序 - 控制面板 -> 管理工具 -> 组件服务。
The problem is that the server process is 64 bit and the library is 32-bit and it tries to create the COM component in the same process (in-proc server). Either you recompile the server and make it 32-bit or you leave the server unchanged and make the COM component out-of-process. The easiest way to make a COM server out-of-process is to create a COM+ application - Control Panel -> Administrative Tools -> ComponentServices.
我遇到了同样的问题,但其他答案只提供了解决方案的一部分。
解决方案有两个:
从寄存器中删除 64 位。
或者
将其注册为 32 位:
C:\Windows\SysWOW64\regsvr32
将其注册为 32 位而不删除 64 位注册并不能解决我的问题。
I had the same issue, but the other answers only supplied one part of the solution.
The solution is two fold:
Remove the 64bit from the Register.
or
Register it as 32bit:
C:\Windows\SysWOW64\regsvr32 <file.dll>
Registering it as 32bit without removing the 64bit registration does not resolve my issue.
我没有更改任何编译设置。
只需在 AppPool 高级设置中设置“启用 32 位应用程序 = True”即可。
这对我有用
I didn't change any compile settings.
Just set "Enable 32-bit Application = True" in AppPool Advanced Settings.
It worked for me
windows 2008 server x64的解决办法是:
此过程有效,没问题。
The solution for windows 2008 server x64 is:
This procedure is valid, it is ok.
有一个相关的问题,有一个不同但相似的修复:
我有一个使用 64 位 DLL 的 Windows 服务项目设置为“Any-CPU”。 同样的错误消息。 尝试了很多事情,但没有任何效果。 最后,我进入项目属性-> 构建并注意到该项目已选中“首选 32 位”。 取消选中此选项,不再出现错误。
我的猜测是 Windows 服务需要 32 位 DLL,但找不到它。
Had a related issue with a different, but similar fix:
I had a Windows service project set to "Any-CPU" using a 64-bit DLL. Same error message. Tried a whole bunch of things, but nothing worked. Finally, I went into project Properties -> Build and noticed that project had "Prefer 32-bit" checked. Unchecked this and no more error.
My guess is that the windows service was expecting a 32-bit DLL, and couldn't find it.
要更改为 x86:
To change to x86:
如果您正在运行网站,您还可以尝试将应用程序池设置为禁用 32 位应用程序(在池的高级设置下)。
If you are running a website, you could also try to set your application pool to disable 32-bit Applications (under advanced settings of a pool).
我发现我的问题与DLL的实际注册有关。
C:\Windows\SysWow64\RegSvr32.exe c:\Windows\SysWow64\Redemption.dll 按回车键。
I found that my problem related to the actual registration of the DLL.
C:\Windows\SysWow64\RegSvr32.exe c:\Windows\SysWow64\Redemption.dll the press enter.
就我个人而言,通过在开发人员计算机上的 Windows 注册表中搜索类 ID 来解决该问题(因为该问题是在客户端 PC 中引发的)。 此操作将被放入导致问题的 COM 组件中:我的 .NET 项目中引用的 x86 库未针对安装程序或更新程序应用程序注册为 OCX/COM。
问候
In my personal case the issue was fixed searching for the class id in the Windows's Registry on developer machine (because the issue was thrown in a client PC). This action will be placed into the COM component that causes the issue: an x86 library referenced in my .NET project that was not being registered as OCX/COM for the installer or updater application.
Regards
对于任何使用 VSTO 的人来说,我的问题是缺少对 Office 程序集的引用。 如果您尝试手动实例化某些 VSTO 对象,它也会出现。
For anyone using VSTO, the problem for me was a missing reference to the
office
assembly. It would also appear if you were trying to instantiate certain VSTO objects manually.已接受的答案,将目标平台更改为 x86 在可能的情况下不起作用!
当我安装了 Visual Studio 的 Crystal Report 并且 Crystal Report 运行时引擎(64 位)在我的情况下工作了!
其他人建议,这个问题可以通过同时安装 32 位和 64 位运行时引擎来解决!
你可以尝试一下!
Accepted answer, changing target platform to x86 did not work in may case!
When I have installed crystal report for visual studio and crystal report runtime engine (64-bit) worked in my case!
Some other suggests that, this problem could be resolved by installing both 32-bit and 64-bit runtime engine!
You may give a try!
我的问题是我的项目参考中的 MS Sync FrameWork 版本 (1.0) 错误。 更新到2.1版本后,错误消失了,生活再次美好。
My problem was that I had the wrong MS Sync FrameWork version (1.0) in my project References. After update to the version 2.1, the error was gone and life is good again.
就我而言,我正在生成 MS Office 文件,例如
word
或excel
,我运行Win+R
并执行dcomcnfg,在DCOM Config中,除了选择OFFICE相关的名称项(如名称中包含
Excel
或Word
或Office
)和打开属性,选择“身份”选项卡,然后选择交互式用户。
为 这个答案,我的错误消息显示
CLSID {000209FF-0000-0000-C000-000000000046}
,所以我必须尝试找到这个特定的DCOM 配置中的 CLSID,它确实存在,我选择它并按照相同的步骤设置交互式用户
,然后它就可以工作了。In my case, I'm producing ms office file like
word
orexcel
, I runWin+R
and executedcomcnfg
, in the DCOM Config, besides select OFFICE related name item (such as name containsExcel
orWord
orOffice
) andOpen the properties, select Identity tab and select the interactive user.
as this answer,My error message show
CLSID {000209FF-0000-0000-C000-000000000046}
, so I have to try to find this specific CLSID in DCOM Config, and it does exsits, and I select it and follow same step set theinteractive user
, then it works.