如何修复 COMException 错误 80040154?

发布于 2024-12-01 14:37:01 字数 642 浏览 2 评论 0原文

将工作的 C# 项目从 64 位 Windows 7 计算机移动到 32 位 XP 计算机会导致以下错误:

由于以下错误,检索 CLSID 为 {681EF637-F129-4AE9-94BB-618937E3F6B6} 的组件的 COM 类工厂失败:80040154。

681EF637-F129-4AE9-94BB-618937E3F6B6 code> 不在注册表中,所以它未正确安装,但这与之前在 64 位 Windows 7 计算机上出现的问题相同。

找到了64位Windows 7机器上此错误的解决方案此处(将 Platform Target 更改为 x86)但这并不能解决 32 位 XP 上的问题 机器。

如何找到与 681EF637-F129-4AE9-94BB-618937E3F6B6 关联的 DLL,或者更好的是,如何修复此异常?

Moving a working C# project from a 64-bit Windows 7 machine to a 32-bit XP machine caused the following error:

Retrieving the COM class factory for component with CLSID {681EF637-F129-4AE9-94BB-618937E3F6B6} failed due to the following error: 80040154.

681EF637-F129-4AE9-94BB-618937E3F6B6 is not in the registry so it is not properly installed, but this is same ID that was previously a problem on the 64-bit Windows 7 machine.

The solution to this error on the 64-bit Windows 7 machine was found here (change Platform Target to x86) but this does not solve the problem on the 32-bit XP machine.

How do I find the DLL associated with 681EF637-F129-4AE9-94BB-618937E3F6B6, or, even better, how do I repair this exception?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(4

彻夜缠绵 2024-12-08 14:37:01

要查找 DLL,请转到 64 位计算机并打开注册表。找到名为 HKEY_CLASSES_ROOT\CLSID\{681EF637-F129-4AE9-94BB-618937E3F6B6}\InprocServer32 的键。该键将 DLL 的文件名作为其默认值。

如果您通过重新编译 x86 项目解决了 64 位计算机上的问题,那么您需要查看注册表的 32 位部分,而不是正常位置。这是HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Classes\CLSID\{681EF637-F129-4AE9-94BB-618937E3F6B6}\InprocServer32

如果 DLL 是为 32 位构建的,那么您可以直接在 32 位计算机上使用它。如果它是为 64 位构建的,那么您必须联系供应商并从他们那里获取 32 位版本。

当您拥有 DLL 后,通过运行 c:\windows\system32\regsvr32.exe 来注册它。

To find the DLL, go to your 64-bit machine and open the registry. Find the key called HKEY_CLASSES_ROOT\CLSID\{681EF637-F129-4AE9-94BB-618937E3F6B6}\InprocServer32. This key will have the filename of the DLL as its default value.

If you solved the problem on your 64-bit machine by recompiling your project for x86, then you'll need to look in the 32-bit portion of the registry instead of in the normal place. This is HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Classes\CLSID\{681EF637-F129-4AE9-94BB-618937E3F6B6}\InprocServer32.

If the DLL is built for 32 bits then you can use it directly on your 32-bit machine. If it's built for 64 bits then you'll have to contact the vendor and get a 32-bit version from them.

When you have the DLL, register it by running c:\windows\system32\regsvr32.exe.

嗳卜坏 2024-12-08 14:37:01

我在 Windows 服务中遇到了同样的问题。所有键都位于注册表中的正确位置。该服务的构建是针对 x86 完成的,但我仍然遇到异常。我发现了 CorFlags.exe

在您的 service.exe 上运行此命令(不带标志)以验证您是否在 32 位下运行。如果没有使用标志 /32BIT+ /Force 运行它
(仅对签名的程序集强制)

如果您打开了 UAC,您可能会收到以下错误:corflags : error CF001 : Could not open file forwriting 给予用户对程序集的完全控制权。

这是应该的屏幕截图(就我而言):
控制台输出

I had the same issue in a Windows Service. All keys where in the right place in the registry. The build of the service was done for x86 and I still got the exception. I found out about CorFlags.exe

Run this on your service.exe without flags to verify if you run under 32 bit. If not run it with the flag /32BIT+ /Force
(Force only for signed assemblies)

If you have UAC turned you can get the following error: corflags : error CF001 : Could not open file for writing Give the user full control on the assemblies.

This is the screenshot how it should be (in my case):
Console output

情深已缘浅 2024-12-08 14:37:01

解决方法:

可能的解决方法是将项目的平台从“任何 CPU”修改为“X86”(在项目的属性、构建/平台的目标中)

根本原因

VSS Interop 是使用 32 位框架的托管程序集,并且 dll 包含 32 位COM 对象。如果您在 64 位环境中运行此 COM dll,您将收到错误消息。

WORKAROUND:

The possible workaround is modify your project's platform from 'Any CPU' to 'X86' (in Project's Properties, Build/Platform's Target)

ROOTCAUSE

The VSS Interop is a managed assembly using 32-bit Framework and the dll contains a 32-bit COM object. If you run this COM dll in 64 bit environment, you will get the error message.

浮云落日 2024-12-08 14:37:01

将表单中全局声明的 Excel 变量移动到本地,就像我的表单中一样:

Dim xls As New MyExcel.Interop.Application  
Dim xlb As MyExcel.Interop.Workbook

上面两行在我的表单中声明为全局,所以我将这两行移动到本地函数,现在工具工作正常。

Move excel variables which are global declare in your form to local like in my form I have:

Dim xls As New MyExcel.Interop.Application  
Dim xlb As MyExcel.Interop.Workbook

above two lines were declare global in my form so i moved these two lines to local function and now tool is working fine.

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