.net CLR在VBA(Access)中的后期绑定

时间:2021-07-11 15:41:27

In the follow post it shows how one can use VBA, create a instance of the CLR and thus call/use/consume .net COM objects without having to register such objects.

在后面的文章中,它展示了如何使用VBA,创建CLR的实例,从而调用/使用/使用.net COM对象,而无需注册这些对象。

Side-By-Side COM Interop with C# and VBA

与C#和VBA并排COM互操作

I looking to replace this code:

我想替换这段代码:

Dim Host As mscoree.CorRuntimeHost
Set Host = New CorRuntimeHost

With

Set Host = createObject("mscoree.CorRunTimeHost")

I am unable to find the "class" name.

我无法找到“类”名称。

In other words, I want to late bind the CLR. Does anyone know if it is possible to use VBA CreateObject() in place of the having a hard reference from VBA to the above mscore

换句话说,我想延迟绑定CLR。有谁知道是否可以使用VBA CreateObject()代替从VBA到上面的mscore的硬引用

The “reference” set in VBA - > tools is

在VBA - >工具中设置的“参考”是

C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscoree.tlb

In effect I looking to late bind use of the .net CLR via CreateObject()

实际上我期待通过CreateObject()延迟绑定使用.net CLR

1 个解决方案

#1


I believe you may need to register the typelib first (can't confirm ATM because I used regtlibv12.exe to register it before I went hunting for the class name). The class name appears to be "CLRMetaData.CorRunTimeHost".

我相信您可能需要先注册typelib(无法确认ATM,因为我在寻找类名之前使用了regtlibv12.exe来注册它)。类名显示为“CLRMetaData.CorRunTimeHost”。

#1


I believe you may need to register the typelib first (can't confirm ATM because I used regtlibv12.exe to register it before I went hunting for the class name). The class name appears to be "CLRMetaData.CorRunTimeHost".

我相信您可能需要先注册typelib(无法确认ATM,因为我在寻找类名之前使用了regtlibv12.exe来注册它)。类名显示为“CLRMetaData.CorRunTimeHost”。