制作一个DLL COM访问 [英] Making a DLL COM accessible

查看:238
本文介绍了制作一个DLL COM访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个类库.NET编写的,我想提供给VB6 / VBA。我试过没有工作(很明显,因为我问这个问题)。这是我做的:

  1. 我在Visual Studio中创建一个库类Project 2010中前preSS并把code类模块。
  2. 我打开项目属性,去大会信息,并检查使COM可见。
  3. 我去了高级编译选项,并有针对性的.Net 2.0(这是非常简单的code)。
  4. 然后,我删除了所有引用期待系统。
  5. 我建的项目(无警告或错误),并复制出的DLL Bin文件夹到C:\ WINDOWS \ SYSTEM32 \
  6. 在我跑了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:

  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:\Windows\System32\
  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?

解决方案

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屋!

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