ASP错误0177: 8007007e,CreateObject无法为COM DLL创建实例。

7
我们一直在尝试在新服务器上安装COM DLL。接口是经典ASP。Map Connector DLL似乎是问题所在,但我能做到的就只有这些。
我们无法让IIS提供除了500错误之外的任何页面。
跟踪ASP时:
127. -ASP_SCRIPT_TRACE_COM_CALL_END
FilePath C:\INETPUB\WWWROOT\MILER\GLOBAL.ASA
LineNumber 6
CurrentStatement set g_pcmsrv=Server.CreateObject("PCMServer.PCMServer")
SizeOfStatement 55
0 ms
128. -ASP_LOG_ERROR
LineNumber 6
ErrorCode ASP 0177 : 8007007e
Description Server.CreateObject Failed
该DLL位于中的PCMSRV32.DLL GLOBAL.ASA:
Sub Application_OnStart


set g_pcmsrv=Server.CreateObject("PCMServer.PCMServer")
set application("g_pcmsrv") = g_pcmsrv

set g_pcmmapmgr=Server.CreateObject("Pcmgole.PCMMapMgr")
set application("g_pcmmapmgr") = g_pcmmapmgr


End Sub

Sub Session_OnStart
set Session("currentTrip") = application("g_pcmsrv").NewTrip("NA")
set Session("map") = application("g_pcmmapmgr").createMap()
End Sub

Sub Session_OnEnd
set Session("currentTrip") = Nothing
set Session("map") = Nothing
End Sub

Sub Application_Onend
Set application("g_pcmsrv")=Nothing
Set application("g_pcmmapmgr")=Nothing
End Sub

DLL文件是否已经被移动或重命名 - 可参考 http://support.persits.com/show.asp?code=ps02061296 或者 https://www.chilkatsoft.com/p/p_474.asp - John
像 @John 所说,它可能没有使用 regsvr32 dllname 注册,还要记得在多种架构环境中使用正确的版本。例如,如果 IIS Web 应用程序池以 32 位模式运行,则需要使用 32 位 regsvr32 注册 DLL。 - user692942
1个回答

36
以下建议适用于在 中使用Server.CreateObjectCreateObject
Web服务器部分是针对的,但仍值得一读。

什么导致了这个错误?

Server.CreateObject 失败

通常情况下,当 Web 应用程序在没有理解使用外部 COM 组件并在 Web 服务器上注册的情况下从一个 Web 服务器移动到另一个 Web 服务器时,会出现此错误。

来自 PRB: Server.CreateObject Returns HTTP 500.100 or ASP 0177 Error (0x8007007E)

当您尝试使用 Server.CreateObject 方法实例化未在本地系统上注册的对象时,会出现此错误。

确定错误来源

如果您在 ASP Web 应用程序中使用 COM 组件,则会看到类似于以下行:

set g_pcmsrv=Server.CreateObject("PCMServer.PCMServer") 

通常错误会指向Set行,这使得识别原因更容易(幸运的是你已经有一些很好的跟踪代码了,所以更好)

如果您不知道DLL位于何处怎么办?

注意: 访问Windows注册表时请小心,因为很容易无意中进行更改,这对操作系统产生严重后果,在极端情况下需要系统还原或重新安装/修复。

CreateObject方法内的字符串称为ProgId,用作标识符,指向Windows注册表中的一个键,可以在其中找到该键

注意: 在大多数Windows版本中,可以使用regedit.exe(也称为注册表编辑器)浏览Windows注册表。使用此工具浏览Windows注册表时要非常小心。

HKEY_CLASSES_ROOT

并且通过扩展

HKEY_LOCAL_MACHINE\Classes

每当ASP处理器遇到一个ProgId时,它会尝试访问Windows注册表并查找相应的键,以确定已注册的COM可访问DLL的位置。
HKEY_CLASSES_ROOT\PCMServer.PCMServer

一种常见的方法是,关键字包含一个名为CLSID的子键,它指向与注册的DLL相关联的类GUID。一旦在注册表中找到GUID关键字,
HKEY_CLASSES_ROOT\CLSID

使用Hive查找子键位置

Hive可以通过查找子键来找到位置。

HKEY_CLASSES_ROOT\CLSID\{GUID from CLSID}\InprocServer32

位置将存储在(默认)值中。

Example Using the ProgId - Scripting.FileSystemObject

  1. Locate Scripting.FileSystemObject subkey in HKEY_CLASSES_ROOT

    HKEY_CLASSES_ROOT\Scripting.FilesystemObject
    
  2. Identify GUID from subkey CLSID

    HKEY_CLASSES_ROOT\Scripting.FilesystemObject\CLSID
    
    (default) - "{0D43FE01-F093-11CF-8940-00A0C9054228}"  
    
  3. Use GUID to find registered DLL subkey in HKEY_CLASSES_ROOT\CLSID

    HKEY_CLASSES_ROOT\CLSID\{0D43FE01-F093-11CF-8940-00A0C9054228}
    
  4. Check subkey InprocServer32 (default) value for the DLL location

    HKEY_CLASSES_ROOT\CLSID\{0D43FE01-F093-11CF-8940-00A0C9054228}\InprocServer32
    
    (default) - "C:\Windows\System32\scrrun.dll"
    

注册表中没有PCMServer.PCMServerProgId?

如果您在注册表中找不到相应的ProgId,可能是由于以下两个原因之一:

  1. DLL未注册。
  2. DLL已在错误的区域注册。

如何在Windows中注册COM DLL

可以通过使用具有提升权限的Windows命令提示符中的regsvr32.exe工具来注册COM DLL并创建相应的注册表条目(这因Windows版本而异)

但在继续之前,操作系统的架构和ASP Web应用程序使用的模式非常重要。

大多数新硬件都是64位的,这在Windows中产生了一个难题,因为它现在必须支持更新的64位架构,同时仍然支持32位架构。微软想出的解决方案是将操作系统分成两个部分,所以我们有64位元素和32位元素。主要的操作系统程序被分解成两个文件夹(只有在64位操作系统上才有,因为32位操作系统不必处理64位,即使硬件有能力)

注意: 在仅有32位的系统上,只需使用64位位置来存储系统文件和Windows注册表。

在64位操作系统上,系统程序位于

  1. For 64 Bit programs

    %SystemRoot%\System32\
    
  2. For 32 Bit programs

    %SystemRoot%\SysWOW64\
    
这也适用于Windows注册表。
  1. 64 Bit

    HKEY_CLASSES_ROOT
    
  2. 32 Bit

    HKEY_CLASSES_ROOT\Wow6432Node
    
例如,在 Windows 的 64 位版本中,以下命令将在 32 位注册表中注册 PCMSRV32.DLL 并创建相关的 COM DLL 注册表键。
C:\Windows\SysWOW64>regsvr32 "C:\Windows\PCMSRV32.DLL"

IIS应用程序池

随着所有东西都开始支持64位,包括IIS,您仍然需要支持只支持32位COM的旧应用程序,因此在IIS 6.0中引入了应用程序池设置下的可配置属性Enabled32BitAppOnWin64(从Windows Server 2003 Service Pack 1开始)。该属性允许应用程序池在64位Windows上以32位模式运行。

因此,在注册COM DLL之前,您需要知道应用程序池是否在32位模式下运行。在IIS 7.0及以上版本中,您可以在IIS管理器应用程序中的应用程序池属性中检查此设置。该设置在“常规”部分下的“高级设置”中,称为“启用32位应用程序”(也可以在<ApplicationPools>部分下使用enable32BitAppOnWin64applicationHost.config中进行配置)。

  • If Enable 32-Bit Applications is set to False

    The IIS Application Pool is running in native 64 Bit mode and any COM DLLs that need to be used by the ASP Web Application will need to support 64 Bit and be registered using the 64 Bit version of regsvr32.exe to be added into the 64 Bit registry.

    C:\Windows\System32>regsvr32 "C:\Windows\PCMSRV32.DLL"
    
  • If Enable 32-Bit Applications is set to True

    The IIS Application Pool is running in 32 Bit Mode and any COM DLLs that need to be used by the ASP Web Application will need to be 32 Bit COM DLLs and be registered using the 32 Bit version of regsvr32.exe to be added into the 32 Bit registry.

    C:\Windows\SysWOW64>regsvr32 "C:\Windows\PCMSRV32.DLL"
    

使用错误版本的 regsvr32.exe 注册 COM DLL

例如,使用:

C:\Windows\SysWOW64>regsvr32 "C:\Windows\PCMSRV32.DLL"

在64位Windows版本中,当IIS应用程序池不处于32位模式时,将COM DLL注册到32位注册表中会导致ASP 500.100内部服务器错误。

服务器对象错误 'ASP 0177: 8007007e'

Server.CreateObject 失败


COM DLL清单

  1. What is the IIS Application Pool Advanced Setting Enable 32-Bit Applications set to, as it impacts on how you register the COM DLL?

  2. Is the DLL registered using the architecture-specific version of regsvr32.exe (if Windows version isn't 64 Bit use the default) that reflects the setting of Enable 32-Bit Applications?

  3. Does the Windows Registry contain a ProgId for the DLL in the architecture-specific location of

    HKEY_CLASSES_ROOT
    

    that reflects the setting of Enable 32-Bit Applications?

  4. Does the InprocServer32 key contain the correct location for the DLL?

  5. In the context of the account I'm using to access the COM DLL (ApplicationIdentity, LocalSystem, NetworkService etc), do I have permission to access both the physical DLL file and the registry entries?


有用的链接


2
@pho3nix 从未被告知此次编辑,但已将其回滚,因为它是100%错误的,并且完全改变了答案的解释方式。在64位操作系统上,程序的64位版本存在于默认系统文件夹%systemroot%\System32中(我知道它说的是32位,但那是微软不想破坏现有东西,而且在我看来没有意义),而32位程序存储在%systemroot%\SysWOW64文件夹中,而不是相反。这也适用于注册表,因此已将您的更改回滚。 - user692942

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接