从 Microsoft Access VBA 引用 .NET Core DLL [英] Referencing a .NET Core DLL from Microsoft Access VBA

查看:29
本文介绍了从 Microsoft Access VBA 引用 .NET Core DLL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个内置于 Microsoft Access 的应用程序,它需要引用 .NET Core 3.0 类库.我尝试使用本文中的过程构建 .NET Core DLL,以 .NET Core 3.0 作为目标框架.

I have an app built in Microsoft Access that needs to reference a .NET Core 3.0 class library. I tried building the .NET Core DLL using the procedure in this article, with .NET Core 3.0 as the target framework.

https://docs.microsoft.com/en-us/dotnet/core/native-interop/expose-components-to-com

但是当我尝试引用 comhost DLL 时,我收到一个对话框,其中显示消息无法添加对指定文件的引用."

But when I attempt to reference the comhost DLL I get a dialog box with the message, "Can't add a reference to the specified file."

从 Microsoft Access VBA 引用 .NET Core 类库的秘诀是什么?

What's the secret to referencing a .NET Core class library from Microsoft Access VBA?

推荐答案

如果你看你链接的页面,会跳出来:

If you look at the page you linked, this jumps out:

与 .NET Framework 不同,.NET Core 不支持从 .NET Core 程序集生成 COM 类型库 (TLB).该指南是为 COM 接口的本机声明手动编写 IDL 文件或 C/C++ 头文件.

Unlike in .NET Framework, there is no support in .NET Core for generating a COM Type Library (TLB) from a .NET Core assembly. The guidance is to either manually write an IDL file or a C/C++ header for the native declarations of the COM interfaces.

VBA 需要一个类型库来引用外部 DLL.由于 .NET Core 不支持生成类型库,因此您无法引用 .NET Core COM DLL.

VBA needs a type library to reference an external DLL. Since .NET Core does not support generating type libraries, you can't reference .NET Core COM DLLs.

但是,您可以使用后期绑定,而根本不引用 DLL.这意味着您必须使用 CreateObject 创建对象,并且将缺乏对智能感知、编译时错误和事件的支持.

However, you can work with late binding and not reference the DLL at all. This means you'll have to create objects with CreateObject and will lack support for intellisense, compile-time errors and events.

这篇关于从 Microsoft Access VBA 引用 .NET Core DLL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆