问题描述
我有一个使用 COM DLL 的 VB6 应用程序.DLL 是用 C# 编写的.在 C# 项目属性中,我检查了Register for COM interop
".选项.VB6 应用程序在我的开发机器上运行良好.C# 代码完全遵循以下格式:CodeProject C# COM 示例
I have a VB6 application that uses a COM DLL. The DLL is written in C#. In the C# project properties I have checked the "Register for COM interop
" option. The VB6 app works fine on my development machine. The C# code follows this format exactly: CodeProject C# COM Example
部署到其他机器时,Regsvr32.exe
尝试注册 DLL 时出现以下错误:
When deploying to other machines, Regsvr32.exe
gives me the following error when I try to register the DLL:
模块MyCOM.dll";已加载但未找到入口点 DLLRegisterServer.
The module "MyCOM.dll" was loaded but the entry-point DLLRegisterServer was not found.
这是什么意思?
我读过的关于 COM DLL 的教程/文档中没有任何关于entry-point DLLRegisterServer"的内容.
What does this mean?
No tutorials/documentation I've read about COM DLLs say anything about "entry-point DLLRegisterServer".
我们在不同的机器上使用 RegAsm.exe
时遇到了重大问题,所以我们真的需要一个可以运行 regsvr32.exe
的解决方案,它适用于任何机器我们部署到的(即 XP、Vista、Windows 7、x86 机器、x64 机器等)
We have had MAJOR problems using RegAsm.exe
on different machines, so we really need a solution where we can run regsvr32.exe
instead that will work for any machine that we deploy to (i.e. XP, Vista, Windows 7, x86 machines, x64 machines, etc.)
我需要在我的 C# 代码中添加什么内容才能使其能够通过 regsvr32.exe
进行注册?
What do I need to add to my C# code to make it register-able with regsvr32.exe
?
推荐答案
你不能.托管 [ComVisible] 类库需要注册到 Regasm.exe.
You can't. Managed [ComVisible] class libraries need to be registered with Regasm.exe.
您可以在 IDE 中使用 Project + Properties、Build 选项卡、Register for COM interop 复选框进行操作.如果您运行 Regasm.exe,您通常需要/codebase 命令行选项,因此您不必将程序集放在 GAC 中.另一个选择是让 Regasm.exe 使用/regfile 选项生成一个 .reg 文件.您只需在目标机器上运行它即可更新注册表.
You can do it from the IDE with Project + Properties, Build tab, Register for COM interop checkbox. If you run Regasm.exe you usually want the /codebase command line option so you don't have to put the assembly in the GAC. Yet another option is to let Regasm.exe generate a .reg file with the /regfile option. You'd just run that on the target machine to get the registry updated.
刚刚看到主要问题"的评论.请注意它们是什么,简称/codebase.您必须在 64 位机器上选择正确的版本.那里有两个.而且您需要一个提升的命令提示符,以便 UAC 不会阻止它.
just saw the "major problems" remark. Note sure what they are, short from /codebase. You do have to pick the right version on 64-bit machines. There are two. And you need an elevated command prompt so that UAC don't put a stop to it.
这篇关于如何使用 Regsvr32 注册 .NET COM DLL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!