如何使用Regsvr32注册.NET COM DLL? [英] How do I register a .NET COM DLL with Regsvr32?

查看:336
本文介绍了如何使用Regsvr32注册.NET COM DLL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用COM DLL的VB6应用程序. DLL是用C#编写的.在C#项目属性中,选中了注册COM互操作"选项. 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 the "Register for COM interop" option checked. The VB6 app works fine on my development machine. The C# code follows this format exactly: CodeProject C# COM Example

当部署到其他计算机时,当我尝试注册DLL时,Regsvr32.exe给我以下错误:

When deploying to other machines, Regsvr32.exe gives me the following error when I try to register the DLL:

The module "MyCOM.dll" was loaded but the entry-point DLLRegisterServer was not found.

这是什么意思?我读过的有关COM DLL的任何教程/文档都没有关于入口点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.)

要在regsvr32.exe中可注册,我需要在C#代码中添加些什么?

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的项目+属性",构建"选项卡,注册COM互操作"复选框来执行此操作.如果运行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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆