Home > OS >  Can I connect a .NET 5 COM interop object with VB6?
Can I connect a .NET 5 COM interop object with VB6?

Time:10-08

I have been doing some research on .NET Core COM interop and enter image description here

e) Create a VB6 project, add this VB6 code:

Private Sub Form_Load()

    Dim obj As Object
    Set obj = CreateObject("new:{cfb2ee8b-f2ec-447c-9f0d-ac19c9a6cc26}") // TODO: use the same GUID!

    MsgBox obj.SayHello()

End Sub

f) Run

enter image description here

Note 1: you can use a ProgId attribute too, like COM object often do, you don't have to stick to Guids only...

Note 2: I've only used IDispatch ("Lazy Loading") interface for this demonstration but you can use IUnknown-derived interfaces ("Early Loading") and TLBs too. Unfortunately .NET 5 doesn't create the .TLB for you, you'll have to build it by yourself or create it with another tool and import it in .NET and/or in VB6.

  • Related