How do I expose a .netstandard2.0 library with COM for use in VB6?

后端 未结 3 1237
春和景丽
春和景丽 2020-12-11 06:16

I have a dotnet core library, a framework 4.7.2 library and a vb6 application.

I want to write a common library for them all to access and so choose .netstandard2.0<

3条回答
  •  悲哀的现实
    2020-12-11 06:49

    A reminder to myself

    • Use a demo UI to access the original DLL to confirm the call works. ( if you can't get it to work skip to making the App.Config for the unit test project using BindingRedirectGenerator )

    • Add a unit test in the com visible project to confirm the call works.

    • Copy all the dlls created by both projects to the release folder

    For each com visible dll run as Administrator

    c:\windows\microsoft.net\framework\v4.0.30319\regasm /verbose /codebase /tlb:MyLibrary.tlb c:\myproject\releasedlls\MyLibrary.dll
    
    • Install BindingRedirectGenerator to c:\brg say

    • At the command prompt change directory to c:\brg

        BindingRedirectGenerator c:\myproject\releasedlls App.config
      
    • Rename App.config to MyVB6Project.exe.config and copy it to the same folder as MyVB6Project.exe

    Remember to set up the files for the vb6.exe folder if you want to run it in the vb6 ide

    Put the whole process in a script for future use ( I used a .bat)

    Keep an eye on what nuget has put in app.config

    Pay attention to the yellow warnings at build time!

提交回复
热议问题