.NET Object from VB6 without use of regasm.exe?

后端 未结 4 710
醉话见心
醉话见心 2020-12-16 07:20

The software company I\'m working for builds software for schools, and so our client machines are usually locked down in such a way it makes it pretty impossible for us to i

4条回答
  •  北海茫月
    2020-12-16 07:53

    You could host the CLR inside Access:

    Add a reference to mscoree (Probably C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscoree.tlb)

    Sub Main()
        Dim CORHost As New mscoree.CorRuntimeHost
        Dim Domain As Object
        Dim AssemblyFilename As String
        Dim Classname As String
        Dim Result As Object
    
        AssemblyFilename = "mscorlib"
        Classname = "System.Collections.ArrayList"
    
        CORHost.Start
        CORHost.CurrentDomain Domain
        Set Result = Domain.CreateInstance(AssemblyFilename, Classname).Unwrap()
    
        Result.Add "test"
        MsgBox Result.Count
    End Sub
    

    This bypasses the need to use the registry. The down side of this is you have to use late binding with your objects.

    You can also add a reference to mscorlib.tlb to get type information for the AppDomain class and others.

提交回复
热议问题