Making a DLL COM accessible

后端 未结 4 551
轻奢々
轻奢々 2020-12-11 17:12

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

相关标签:
4条回答
  • 2020-12-11 17:31

    Use GacUtil instead of RegSvr32. RegSvr is used for dll's made with VB6 and for the .NET DLL's you need to use GacUtil because it is added to the global assembly cache.

    0 讨论(0)
  • 2020-12-11 17:33

    You'll need to define GUIDs for your interfaces and mark which classes implement which interfaces, to start. MSDN has a getting started guide. You don't need to run RegSvr32, but you do need to put the DLL somewhere where the app can find it:

    After registering an assembly using Regasm.exe, you can install it in the global assembly cache so that it can be activated from any COM client. If the assembly is only going to be activated by a single application, you can place it in that application's directory.

    There is also a good overview of the whole process here.

    0 讨论(0)
  • 2020-12-11 17:42

    I am fairly certain RegSvr32 only works on non.NET DLL. .NET assemblies are stored in the Global Assembly Cache (GAC). You have to run the gacutil.exe.

    0 讨论(0)
  • 2020-12-11 17:57

    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.

    0 讨论(0)
提交回复
热议问题