由于以下错误,检索 CLSID {XXXX} 的组件的 COM 类工厂失败:80040154

发布于 2024-07-25 06:24:35 字数 454 浏览 2 评论 0原文

我使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(18

最丧也最甜 2024-08-01 06:24:35

在VS中-项目属性-在构建选项卡中-平台目标=X86

In VS - project properties - in the Build tab - platform target =X86

调妓 2024-08-01 06:24:35

我遇到了一个非常相似的问题。

我需要在 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.

鲜肉鲜肉永远不皱 2024-08-01 06:24:35

听起来您的服务是针对“任何 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.

涙—继续流 2024-08-01 06:24:35

如果您正在寻找一种无需重新编译 Any CPU 应用程序即可完成此操作的方法,这里有另一个潜在的解决方法:

  1. 在 HKey_Classes_Root\Wow6432Node\CLSID\{GUID} 下找到 COM 对象 GUID
  2. 找到后添加新的 REG_SZ (字符串)值。 名称应为 AppID,数据应与您刚刚搜索的 COM 对象 GUID 相同
  3. 在 HKey_Classes_Root\Wow6432Node\AppID 下添加一个新项。 新密钥的名称应与 COM 对象 GUID 的名称相同。
  4. 在刚刚添加的新键下,添加一个新的字符串值,并将其命名为 DllSurrogate。 将值留空。
  5. 在 HKey_Local_Machine\Software\Classes\AppID\ 下创建一个新的 Key
    同样,新密钥的调用方式应与 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:

  1. Locate your COM object GUID under the HKey_Classes_Root\Wow6432Node\CLSID\{GUID}
  2. 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
  3. Add a new key under HKey_Classes_Root\Wow6432Node\AppID. The new key should be called the same as the COM object GUID.
  4. Under the new key you just added, add a new String Value, and call it DllSurrogate. Leave the value empty.
  5. 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.

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/

白衬杉格子梦 2024-08-01 06:24:35

您不必配置项目属性平台目标 X86。
您还可以配置 iis 选项以与 x86 一起使用,如下所示

  • 选择应用程序池
  • 选择您的应用程序使用的池
  • 高级设置
  • 启用 32 位应用程序 true

You dont have to configure your project properties platform target X86.
You can also configure the iis options to work with x86 like that

  • Select Application pool
  • Select the pool which your app uses
  • Advanced settings
  • Enable 32 bit applications true
一曲爱恨情仇 2024-08-01 06:24:35

问题是服务器进程是 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.

风尘浪孓 2024-08-01 06:24:35

我遇到了同样的问题,但其他答案只提供了解决方案的一部分。

解决方案有两个:

从寄存器中删除 64 位。

  • c:\windows\system32\regsvr32.exe /U;
  • 这不会删除对其他文件夹中 dll 的其他副本的引用。

或者

  • 找到名为 HKEY_CLASSES_ROOT\CLSID{......}\InprocServer32 的键。 该键将 DLL 的文件名作为其默认值。
  • 我删除了 HKEY_CLASSES_ROOT\CLSID{......} 文件夹。

将其注册为 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.

  • c:\windows\system32\regsvr32.exe /U <file.dll>
  • This will not remove references to other copied of the dll in other folders.

or

  • Find the key called HKEY_CLASSES_ROOT\CLSID{......}\InprocServer32. This key will have the filename of the DLL as its default value.
  • I removed the HKEY_CLASSES_ROOT\CLSID{......} folder.

Register it as 32bit:

  • C:\Windows\SysWOW64\regsvr32 <file.dll>

Registering it as 32bit without removing the 64bit registration does not resolve my issue.

栀子花开つ 2024-08-01 06:24:35

我没有更改任何编译设置。

只需在 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

他夏了夏天 2024-08-01 06:24:35

windows 2008 server x64的解决办法是:

  1. 以管理员权限打开cmd.exe。
  2. 将 dll 复制到文件夹 C:\Windows\SysWOW64
  3. 从 C:\Windows\SysWOW64 运行 regsvr32
  4. 验证 dll 是否在 Windows 注册表中。
  5. 如果您有使用该 dll 的 .exe x86,则必须在 x86 模式下编译该 exe。
  6. exe 必须安装在文件夹 C:\Program Files (x86) 中

此过程有效,没问题。

The solution for windows 2008 server x64 is:

  1. open cmd.exe with Administrator permission.
  2. Copy the dll to the folder C:\Windows\SysWOW64
  3. run regsvr32 from C:\Windows\SysWOW64
  4. Verify that dll is in registry of Windows.
  5. If you has a .exe x86 that use the dll, the exe must be compiled in x86 mode.
  6. The exe must be installed in folder C:\Program Files (x86)

This procedure is valid, it is ok.

七分※倦醒 2024-08-01 06:24:35

有一个相关的问题,有一个不同但相似的修复:

我有一个使用 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.

绝影如岚 2024-08-01 06:24:35

要更改为 x86:

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

To change to x86:

  1. Create a setup project for your solution.
  2. After you create it, Go to Solution Explorer, right click the setup project.
    • Press Configuration Manager.
    • Click on: "Active Solution Platform" combobox and select New (If there is no x86 displayed)
    • Select from first combo x86 then press OK.
    • rebuild Setup project, then rebuild All the project.
永言不败 2024-08-01 06:24:35

如果您正在运行网站,您还可以尝试将应用程序池设置为禁用 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).

蝶…霜飞 2024-08-01 06:24:35

我发现我的问题与DLL的实际注册有关。

  • 首先从 CMD 提示符运行“Regedit.exe”(我将其安全级别提高到管理员,“以防万一”),
  • 然后搜索注册表(通过单击 RegEdit 菜单中的“编辑/查找”或按 Ctrl+F)查看您收到的有关 COM 类工厂的错误消息中显示的 CLSID。 我的 CLSID 是 29AB7A12-B531-450E-8F7A-EA94C2F3C05F。
  • 找到该键后,选择该 Hive 节点下的子键“InProcServer2”,并在右侧 Regedit 框架中确定问题 DLL 的文件名。 显示在“默认”下。
  • 如果该文件位于“C:\Windows\SysWow64”(例如 C:\Windows\SysWow64\Redemption.dll”),那么使用“C:\Windows\SysWow64\RegSvr32.exe”文件来从命令行注册该 DLL,而不是默认的“C:\Windows\System32\RegSvr32.exe”文件,
  • 因此我运行了 CMD 提示符(在管理级别控制下(以防万一需要此级别))并键入命令行(对于我的 DLL):
    C:\Windows\SysWow64\RegSvr32.exe c:\Windows\SysWow64\Redemption.dll 按回车键。
  • 关闭命令窗口(通过“退出”然后重新启动您的计算机(始终使用重新启动而不是关闭然后启动,因为(奇怪的是)重新启动执行彻底关闭并重新加载所有内容,而“关闭”并且 Power-Up 会重新加载驱动程序和其他值的存储缓存(这可能是错误的)。
  • 将来每当您注册 DLL 时,请记住对存储在 C:\Windows 中的任何 DLL 使用 SysWow64“RegSvr32.exe” \SysWow64 文件夹和此问题(如果是由不正确的注册引起的)不应再次发生。

I found that my problem related to the actual registration of the DLL.

  • First run "Regedit.exe" from a CMD prompt (I raised it's security level to Administrator, "just in case")
  • then search the Registry (by clicking on "Edit/Find" in the RegEdit menu or by pressing Ctrl+F) for the CLSID showing in the error message which you received regarding the COM class factory. My CLSID was 29AB7A12-B531-450E-8F7A-EA94C2F3C05F.
  • When this key is found, select the sub-key "InProcServer2" under that Hive node and ascertain the filename of the problem DLL in the right hand Regedit frame. showing under "Default".
  • If that file resides in "C:\Windows\SysWow64"(such as C:\Windows\SysWow64\Redemption.dll") then it is important that you use the "C:\Windows\SysWow64\RegSvr32.exe" file to register that DLL from the command line and NOT the default "C:\Windows\System32\RegSvr32.exe" file.
  • So I ran a CMD prompt (under Administrative level control (just in case this level is need required) and type on the command line (in the case of my DLL):
    C:\Windows\SysWow64\RegSvr32.exe c:\Windows\SysWow64\Redemption.dll the press enter.
  • Close the command window (via "Exit" then Restart your computer (always use restart instead of Close Down then start up, since (strangely) Restart perform a thorough shut down and reload of everything whereas "Shut Down" and Power-Up reloads a stored cache of drivers and other values (which may be faulty).
  • Whenever you register a DLL in the future, remember to use the SysWow64 "RegSvr32.exe" for any DLL stored in the C:\Windows\SysWow64 folder and this problem c(if it is caused by incorrect registration) should not happen again.
傲娇萝莉攻 2024-08-01 06:24:35

就我个人而言,通过在开发人员计算机上的 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

蹲在坟头点根烟 2024-08-01 06:24:35

对于任何使用 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.

玩世 2024-08-01 06:24:35

已接受的答案,将目标平台更改为 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!

enter image description here

ゝ偶尔ゞ 2024-08-01 06:24:35

我的问题是我的项目参考中的 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.

乖乖 2024-08-01 06:24:35

就我而言,我正在生成 MS Office 文件,例如 wordexcel,我运行 Win+R 并执行 dcomcnfg,在DCOM Config中,除了选择OFFICE相关的名称项(如名称中包含ExcelWordOffice)和打开属性,选择“身份”选项卡,然后选择交互式用户。这个答案

我的错误消息显示CLSID {000209FF-0000-0000-C000-000000000046},所以我必须尝试找到这个特定的DCOM 配置中的 CLSID,它确实存在,我选择它并按照相同的步骤设置交互式用户,然后它就可以工作了。

In my case, I'm producing ms office file like word or excel, I run Win+R and execute dcomcnfg, in the DCOM Config, besides select OFFICE related name item (such as name contains Excel or Word or Office) and Open 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 the interactive user, then it works.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文