在 Windows Server 2008 R2 上注册 DLL 文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4550229/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Register DLL file on Windows Server 2008 R2
提问by Broken Link
I'm trying to register a COM DLL file on Windows Server 2008 R2. Here are the steps I took:
我正在尝试在 Windows Server 2008 R2 上注册一个 COM DLL 文件。以下是我采取的步骤:
- Run
cmd
as administrator c:\windows\system32\regsvr32.exe c:\tempdl\temp12.dll
cmd
以管理员身份运行c:\windows\system32\regsvr32.exe c:\tempdl\temp12.dll
When I execute that command I get this error:
当我执行该命令时,出现此错误:
The module
temp12.dll
failed to load. Make sure the binary is stored at the specified path or debut it to check for problems with the binary or dependent.DLL
files. The specified module could not be found.
模块
temp12.dll
加载失败。确保二进制文件存储在指定路径或首次亮相以检查二进制文件或相关.DLL
文件是否存在问题。指定的模块无法找到。
I was able to register the same DLL file on Windows 2000.
我能够在 Windows 2000 上注册相同的 DLL 文件。
I also tried
我也试过
c:\windows\syswow64\regsvr32 "c:\tempdl\temp12.dll"
And I got this error:
我收到了这个错误:
the module
c:\tempdl\temp12.dll
was loaded but the call toDllRegisterServer
failed with error code0x80040154
. For more information about this problem, search online using the error code as the search term
模块
c:\tempdl\temp12.dll
已加载,但调用DllRegisterServer
失败并显示错误代码0x80040154
。有关此问题的更多信息,请使用错误代码作为搜索词在线搜索
回答by Hans Passant
That's the error you get when the DLL itself requires another COM server to be registered first or has a dependency on another DLL that's not available. The Regsvr32.exe tool does very little, it calls LoadLibrary() to load the DLL that's passed in the command line argument. Then GetProcAddress() to find the DllRegisterServer() entry point in the DLL. And calls it to leave it up to the COM server to register itself.
当 DLL 本身需要先注册另一个 COM 服务器或依赖另一个不可用的 DLL 时,就会出现这种错误。Regsvr32.exe 工具做的很少,它调用 LoadLibrary() 来加载在命令行参数中传递的 DLL。然后 GetProcAddress() 在 DLL 中查找 DllRegisterServer() 入口点。并调用它让 COM 服务器自行注册。
What thatcode does is fairly unguessable. The diagnostic you got is however pretty self-evident from the error code, for some reason this COM server needs another one to be registered first. The error message is crappy, it doesn't tell you whatother server it needs. A sad side-effect of the way COM error handling works.
什么是代码确实是相当难以猜测。然而,您得到的诊断从错误代码中是不言而喻的,出于某种原因,这个 COM 服务器需要先注册另一个。错误消息很糟糕,它没有告诉您它需要什么其他服务器。COM 错误处理方式的一个可悲的副作用。
To troubleshoot this, use SysInternals' ProcMon tool. It shows you what registry keys Regsvr32.exe (actually: the COM server) is opening to find the server. Look for accesses to the CLSID key. That gives you a hint what {guid} it is looking for. That still doesn't quite tell you the server DLL, you should compare the trace with one you get from a machine that works. The InprocServer32 key has the DLL path.
要解决此问题,请使用 SysInternals 的 ProcMon 工具。它显示您打开哪些注册表项 Regsvr32.exe(实际上:COM 服务器)以查找服务器。查找对 CLSID 密钥的访问。这给了你一个提示,它正在寻找什么 {guid}。这仍然不能完全告诉您服务器 DLL,您应该将跟踪与从工作机器获得的跟踪进行比较。InprocServer32 项具有 DLL 路径。
回答by Kev
You might need to register this DLL using the 32 bit version of regsvr32.exe
:
您可能需要使用以下 32 位版本注册此 DLL regsvr32.exe
:
c:\windows\syswow64\regsvr32 c:\tempdl\temp12.dll
c:\windows\syswow64\regsvr32 c:\tempdl\temp12.dll
回答by Simon Mourier
Error 0x80040154 is COM's REGDB_E_CLASSNOTREG, which means "Class not registered". Basically, a COM class is not declared in the installation registry.
错误 0x80040154 是 COM 的 REGDB_E_CLASSNOTREG,意思是“类未注册”。基本上,COM 类未在安装注册表中声明。
If you get this error when trying to register a DLL, it may be possible that the registration code for this DLL is trying to instantiate anotherCOM server (DLL or EXE) which is missing or not registered on this installation.
如果您在尝试注册 DLL 时遇到此错误,则可能是该 DLL 的注册代码正在尝试实例化在此安装中丢失或未注册的另一个COM 服务器(DLL 或 EXE)。
If you don't have access to the original DLL source, I would suggest to use SysInternal's Process Monitortool to track COM registry lookups (there use to be a more simple RegMon tool but it may not work any more).
如果您无权访问原始 DLL 源,我建议使用 SysInternal 的Process Monitor工具来跟踪 COM 注册表查找(曾经有一个更简单的 RegMon 工具,但它可能不再起作用)。
You should put a filter on the working process (here: Regsvr32.exe) to only capture what's interesting. Then you should look for queries on HKEY_CLASSES_ROOT\[a progid, a string] that fail (with the NAME_NOT_FOUND error for example), or queries on HKEY_CLASSES_ROOT\CLSID\[a guid] that fail.
您应该对工作过程(此处:Regsvr32.exe)设置过滤器,以仅捕获有趣的内容。然后,您应该在 HKEY_CLASSES_ROOT\[a progid, a string] 上查找失败的查询(例如 NAME_NOT_FOUND 错误),或者在 HKEY_CLASSES_ROOT\CLSID\[a guid] 上查找失败的查询。
PS: Unfortunately, there may be many thing that seem to fail on a perfectly working Windows system, so you'll have to study all errors carefully. Good luck :-)
PS:不幸的是,在一个完美运行的 Windows 系统上可能有很多事情似乎失败了,所以你必须仔细研究所有错误。祝你好运 :-)
回答by nitin jain
I have found similar issue while registering my activeX (OCX) into windows server 2008 R2.To solve this i used http://www.chestysoft.com/dllregsvr/default.asptool.There is some dependance problem with my ocx so I am getting "The module temp12.dll failed to load. Make sure the binary is stored at the specified path or debut it to check for problems with the binary or dependent .DLL files. The specified module could not be found" error message. When you try to registered your OCX with this tool it will prompt message if the ocx is having dependency or you will get success message.I got message for mfc70.dll and msvcr70.dll dependency.so i paste these dll into system32 folder of C:\windows and its done.After that I register my ocx sucessfully.I used 32 bit version of chestysoft tool (dllregsvr.exe) on windows server 2008 R2 64bit machine.
我在将我的 activeX (OCX) 注册到 windows server 2008 R2 时发现了类似的问题。为了解决这个问题,我使用了http://www.chestysoft.com/dllregsvr/default.asp工具。我的 ocx 存在一些依赖性问题,所以我收到“模块 temp12.dll 加载失败。确保二进制文件存储在指定路径或首次亮相以检查二进制文件或相关 .DLL 文件是否存在问题。找不到指定的模块”错误消息。当您尝试使用此工具注册您的 OCX 时,它会提示消息是否 ocx 具有依赖关系,否则您将收到成功消息。我收到了 mfc70.dll 和 msvcr70.dll 依赖关系的消息。所以我将这些 dll 粘贴到 C 的 system32 文件夹中:\windows 和它的完成。之后我成功注册了我的 ocx。我在 windows server 2008 R2 64 位机器上使用了 32 位版本的chestysoft 工具 (dllregsvr.exe)。
回答by TmTron
- Maybe the Microsoft Visual C++ Redistributable Package is not installed on the target machine (or it has the wrong version) download Microsoft Visual C++ Redistributable Package
- Maybe you have not built the .dll with Release config (but with Debug instead) http://www.davidlenihan.com/2008/01/choosing_the_correct_cc_runtim.html
- 可能目标机器上没有安装 Microsoft Visual C++ Redistributable Package(或者版本错误) 下载 Microsoft Visual C++ Redistributable Package
- 也许您还没有使用 Release 配置(而是使用 Debug)构建 .dll http://www.davidlenihan.com/2008/01/choosing_the_correct_cc_runtim.html
回答by DevCompany
This is what has to occur.
这是必须发生的事情。
You have to copy your DLL that you want to Register to: c:\windows\SysWOW64\
您必须将要注册的 DLL 复制到:c:\windows\SysWOW64\
Then in the Run dialog, type this in:
C:\Windows\SysWOW64\regsvr32.exe c:\windows\system32\YourDLL.dll
然后在运行对话框中输入:
C:\Windows\SysWOW64\regsvr32.exe c:\windows\system32\YourDLL.dll
and you will get the message:
您将收到以下消息:
DllRegisterServer in c:\windows\system32\YourDLL.dll succeeded.
c:\windows\system32\YourDLL.dll 中的 DllRegisterServer 成功。
回答by vcsjones
You may need to install ATL if your COM objects use ATL, as described by this KB article:
如果您的 COM 对象使用 ATL,您可能需要安装 ATL,如这篇知识库文章所述:
http://support.microsoft.com/kb/201191
http://support.microsoft.com/kb/201191
These libraries will probably have to be supplied by developers to ensure the correct version.
这些库可能必须由开发人员提供以确保版本正确。
回答by Juls
You need the full path to the regsvr32 so %windir$\system32\regsvr32 <*.dll>
您需要 regsvr32 的完整路径,因此 %windir$\system32\regsvr32 <*.dll>