检索 COM 类工厂失败。错误:80040154

发布于 2024-10-20 12:15:38 字数 1182 浏览 1 评论 0原文

由于以下错误,检索 CLSID 为 {AD37B7D5-B5A3-460A-8FFB-3C71984A4537} 的组件的 COM 类工厂失败:80040154。

异常详细信息:

System.Runtime.InteropServices.COMException:由于以下错误,检索 CLSID 为 {AD37B7D5-B5A3-460A-8FFB-3C71984A4537} 的组件的 COM 类工厂失败:80040154。

我在 ASP.NET Web 中使用 COM DLL应用。我已经成功地让它在我自己的开发机器和构建机器上运行。
但是,当我尝试将项目部署到另一台计算机(Microsoft Windows Server 2003 R2)时,出现上述错误。

我已使用 regsvr32 命令注册了 COM DLL。说明DLL已注册成功。

我正在使用 ASP.NET 3.5 版在 Visual Studio 2008 中开发该项目,并将我的项目构建为在任何 CPU 上运行,每台计算机都使用 64 位 Windows。 我使用的是 IIS 版本 6.0。
(我尝试使 IIS 运行 32 位应用程序,这导致 Web 应用程序不可用。)

我编写了一个 Windows 脚本文件来检查 COM DLL 是否正常工作(即独立于项目)。 这个脚本在我的构建机器和我自己的开发机器上都运行良好。
但是,它在我遇到问题的计算机(Microsoft Windows Server 2003 R2)上无法正常运行。 我所要做的就是使用以下命令从命令行运行脚本(我发现此处):

C:\WINDOWS\SysWOW64\wscript.exe COMtest.js  

wscript 文件在此运行时成功运行方式。
我认为这与构建 COM DLL 的版本有关。

我需要在 Visual Studio 项目中启用某些设置吗?
(请注意,我自己没有构建 COM DLL。其他人构建了它并将其提供给了我。)

Retrieving the COM class factory for component with CLSID {AD37B7D5-B5A3-460A-8FFB-3C71984A4537} failed due to the following error: 80040154.

Exception details:

System.Runtime.InteropServices.COMException: Retrieving the COM class factory for component with CLSID {AD37B7D5-B5A3-460A-8FFB-3C71984A4537} failed due to the following error: 80040154.

I'm using A COM DLL in my ASP.NET Web Application. I have managed to successfully get it working on both my own dev machine and a build machine.
However when I try deploying the project to a different machine (Microsoft Windows Server 2003 R2) I get the above error.

I have registered the COM DLL using the regsvr32 command. It says the DLL was registered successfully.

I am developing the project in Visual Studio 2008 with ASP.NET version 3.5 and building my project to run on any CPU, each machine uses 64-bit Windows.
I'm using IIS version 6.0.
(I have tried enabling IIS to run 32-bit applications, this caused the web application to be unavailable.)

I wrote a Windows script file to check weather the COM DLL was working or not on (i.e. independent from the project).
This script worked fine on both my build machine and my own dev machine.
However it did not run properly on the machine I'm having trouble with (Microsoft Windows Server 2003 R2).
What I had to do was to run the script from the command line using the following command (which I found here):

C:\WINDOWS\SysWOW64\wscript.exe COMtest.js  

The wscript file works succesfully when ran in this way.
I presume it has something to do with the version that the COM DLL was built for.

Do I need to enable some settings in my Visual Studio project?
(Please note I have not built the COM DLL myself. Someone else has built it and given it to me.)

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

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

发布评论

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

评论(3

撩人痒 2024-10-27 12:15:38

这是 COM 的 FileNotFound 错误。在这种情况下,很可能是位数问题。注册表将 32 位和 64 位服务器的 COM 注册分开。当您从 syswow64 目录运行 wscript.exe 时,它​​强烈表明它正在工作,这是 32 位可执行文件的主目录。 64 位进程将无法在注册表中找到 32 位服务器。也将无法使用它。通过运行 c:\windows\system32\wscript.exe 来重现

您首先必须构建 x64 版本的 COM 服务器,以便 64 位进程可以使用它。然后,您必须使用 64 位版本的 Regsvr32.exe 注册它,该版本位于 c:\windows\system32 中,而不是 syswow64 中。如果仍然遇到问题,请使用 SysInterals 的 ProcMon 实用程序来查找进程在注册表和文件系统中的位置。

或者让 IIS 以 32 位模式运行。这是另一个需要不同标签的问题。

It is COM's FileNotFound error. In this case it is very likely to be a bitness problem. The registry keeps COM registration for 32-bit and 64-bit servers separate. Strongly indicated by it working when you run wscript.exe from the syswow64 directory, that's the home for 32-bit executables. A 64-bit process won't be able to find the 32-bit server in the registry. Nor will it be able to use it. Repro that by running c:\windows\system32\wscript.exe

You will first have to build the x64 version of the COM server so a 64-bit process can use it. Then you will have to register it with the 64-bit version of Regsvr32.exe, the one in c:\windows\system32, not syswow64. If you still have trouble then use SysInterals' ProcMon utility to find out where the process is looking in the registry and file system.

Or get IIS to run in 32-bit mode. That's another question that needs different tags.

乙白 2024-10-27 12:15:38

我通过为 dll 创建 COM+ 应用程序解决了这个问题。

I fixed this problem by creating a COM+ application for the dll.

十年不长 2024-10-27 12:15:38

我在使用第三方 .dll 文件时收到 80040154 错误。最后我发现错误是由于尝试了 API 禁止的调用而导致的 - Visual Studio 让我认为它们会没问题。因此,一个答案可能是检查您的 API 调用与 dll 文档(即 RTFM)是否正确!

我想我会添加这个,因为它可能会节省一些人的宝贵时间。

I received the 80040154 error when using a third party .dll file. In the end I found that the error was the result of trying calls that were prohibited by the API - Visual Studio led me to think they would be fine. Therefore, one answer maybe to check that your API calls are correct with the dll documentation i.e. RTFM!

Thought I would add this as it may save somebody some valuable time.

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