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
384 views
in Technique[技术] by (71.8m points)

.net - Making a DLL COM accessible

I have a class library written in .Net that I would like to make available to VB6/VBA. What I tried did not work (obviously as I am asking this question). Here is what I did:

  1. I Created a Class Library Project in Visual Studio 2010 Express and put the code in a Class Module.
  2. I opened the project properties and went to "Assembly Information" and checked "Make COM Visible".
  3. I went to "Advanced Compile" options and targeted .Net 2.0 (it's very simple code).
  4. I then removed all references expect for "System".
  5. I built the project (no warnings or errors) and copied the DLL out of the Bin folder into C:WindowsSystem32
  6. I ran RegSvr32 to register the DLL and got the error:

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

Make sure that "MyDll.dll is a valid DLL or OCX file and then try again.

Clearly my first attempt was a bit naive. Could someone offer guidance?

See Question&Answers more detail:os

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

1 Reply

0 votes
by (71.8m points)

Step #6 is wrong. .NET assemblies with [ComVisible] types are registered with Regasm.exe. Use the /codebase command line option if you don't want to install the DLL into the GAC. The /tlb command line option creates the type library, you can use that in your VB6 project.


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

...