1

I have created a class library in C#, called SimpleCalc on Visual Studio that I want to use in Access VBA.

Following this article I was able to get it working on development laptop.

However, I am now trying to get it working on an end user's computer but I am having trouble figuring it out.

I took the dll file, that was generated by visual studio when I built the project, and copied it over to the user's computer and then I began trying to register it.

To register I need to use the command regsvr32 but that gave me an error saying that DLL was loaded but DllRegister Server entry point was not found.

So I started using Regasm.exe to register the dll.

That was able to register the dll, but when I tried to add reference in the VBA editor on Access I got an error message that says "can't add a reference to the specified file".

Is there anything I overlooked or what should I do?

Cindy Meister
  • 25,071
  • 21
  • 34
  • 43
patreilly
  • 39
  • 1
  • 2
  • 10
  • This may help https://stackoverflow.com/questions/19954001/calling-a-net-library-method-from-vba – Fred Jun 06 '18 at 16:40
  • try `regasm.exe your.dll /codebase` and make sure the bitness (x86 vs x64) is consistent between your VBA and your DLL. – Simon Mourier Jun 06 '18 at 16:44
  • Try `regasm.exe your.dll /codebase /tlb`, and then reference the .tlb file instead of the .dll. – Mathieu Guindon Jun 06 '18 at 16:47
  • VBA does not know anything about .NET assemblies, it needs the type library for the DLL. Plays the exact same role as metadata in an assembly. Should already be present on your dev machine, so just copy it along. Or have Regasm generate it for you with its /tlb option. – Hans Passant Jun 06 '18 at 17:33

1 Answers1

0

As Simon, Mathieu and Hans said in the comments, I needed to use /codebase and reference the .tlb file.

But I also needed to Sign the assembly with a strong name and following this article I was able to do so through Visual Studio.

patreilly
  • 39
  • 1
  • 2
  • 10