How to make a COM DLL?

♀尐吖头ヾ 提交于 2020-01-17 13:42:14

问题


Just another of those things that I have never done before but which is probably simple ... when you know how

I am using VB Express 2008 and need to create a very simple DLL.

I already built and tested it and now I find that it has to be a COM DLL. How do I go about that?


Edit: in reply to @Kman - I looked at http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.comvisibleattribute.aspx

and changed my code to

Imports System.Runtime.InteropServices

Namespace My_DLL

  <ClassInterface(ClassInterfaceType.AutoDual)> _
  Public Class My_DLL

      <ComVisible(True)> Public Sub Function_A()
      End Sub

      <ComVisible(True)> Public Sub Function_B()
      End Sub
  End Class
End Namespace

but I still don't the functions using DLL Explorer, whereas I do see them in the old DLL ...


回答1:


Check http://www.codeproject.com/KB/COM/nettocom.aspx

Maybe http://www.exforsys.com/tutorials/vb.net-2005/creating-and-managing-components-in-vb.net-2005-section-1.html

The MS pages about it are here: http://msdn.microsoft.com/en-us/library/3x7357ez%28vs.71%29.aspx

Follow the suggestions and if you want to learn more check out the following book .NET and Com the Complete Interoperability Guide. Everything is explained there in whatever detail you like.




回答2:


Qualify your dll for interop; mark its ComVisibleAttribute to true.

Right click your project, goto Build tab, and check the last Checkbox, which says "register for COM interop".



来源:https://stackoverflow.com/questions/3623941/how-to-make-a-com-dll

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!