制作一个DLL COM访问 [英] Making a DLL COM accessible
问题描述
我有一个类库.NET编写的,我想提供给VB6 / VBA。我试过没有工作(很明显,因为我问这个问题)。这是我做的:
- 我在Visual Studio中创建一个库类Project 2010中前preSS并把code类模块。
- 我打开项目属性,去大会信息,并检查使COM可见。
- 我去了高级编译选项,并有针对性的.Net 2.0(这是非常简单的code)。
- 然后,我删除了所有引用期待系统。
- 我建的项目(无警告或错误),并复制出的DLL Bin文件夹到C:\ WINDOWS \ SYSTEM32 \
- 在我跑了RegSvr32注册DLL,并得到了错误:
模块MYDLL.DLL已加载,但在入口点的DLLRegisterServer没有被发现。
确保MYDLL.DLL是一个有效的DLL或OCX文件,然后再试一次。
显然,我的第一次尝试是有点幼稚。可能有人提供指导?
步骤#6是错误的。 .NET程序集有[标记有ComVisible特性]类型注册Regasm.exe。如果你不想安装DLL到GAC使用/ codeBase的命令行选项。在/ TLB命令行选项创建类型库,您可以使用您的VB6项目。
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:
- I Created a Class Library Project in Visual Studio 2010 Express and put the code in a Class Module.
- I opened the project properties and went to "Assembly Information" and checked "Make COM Visible".
- I went to "Advanced Compile" options and targeted .Net 2.0 (it's very simple code).
- I then removed all references expect for "System".
- I built the project (no warnings or errors) and copied the DLL out of the Bin folder into C:\Windows\System32\
- 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?
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.
这篇关于制作一个DLL COM访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!