1

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://learn.microsoft.com/en-us/dotnet/core/native-interop/expose-components-to-com

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."

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

1
  • I should mention that I'm using the 32 bit version of Microsoft Access, and I set the .NET Core project's platform target to x86. Commented Jun 16, 2020 at 0:21

1 Answer 1

1

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

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 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.

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you, @Erik-A. You solved the mystery! Much appreciated.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.