Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
705 views
in Technique[技术] by (71.8m points)

c# - How do I register a .NET COM DLL with Regsvr32?

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

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.

What does this mean? No tutorials/documentation I've read about COM DLLs say anything about "entry-point DLLRegisterServer".

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.)

What do I need to add to my C# code to make it register-able with regsvr32.exe?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You can't. Managed [ComVisible] class libraries need to be registered with Regasm.exe.

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.

Edit: 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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...