0

I developed a class library in Visual Studio 2019 using the .NET framework. Before building the project, I registered the.dll file to interop COM, and this process gave me a .tlb file. This class library was developed in VB.NET, besides that, it has a simple code: one class with one function (class calcular, function Soma):

It was possible to include the .tlb file in the reference of VBA and I develop a code in this language that uses the class of VB.NET to build the action of the button:

On the other hand, when I execute the code in VBA Excel it shows this message:

If a press the button debug "Depurar" VBA mark the line of the instance of the class

I read other questions about this error but there isn't a way to solve it without change my machine?

I already made a repair in my MS Office getting to uninstall to install again, can you help me to solve this error that prevents a run of my library in Excel VBA?

GSerg
  • 76,472
  • 17
  • 159
  • 346
DeSanterra
  • 81
  • 1
  • 1
  • 8

2 Answers2

1

.NET COM visible dlls should be registered using regasm utility with /codebase option.

Assembly Registration Tool

Smith
  • 710
  • 1
  • 7
  • 11
-1

You must register the DLL before it can be used. Every time you compile a new version you need to run:

regsvr32.exe "fullPathAndFileName.dll"

You can add a post-build event to the Release in Visual Studio so that it registers the DLL every time you make a new release. If you are distributing this for others then you will need an installer that puts the DLL in to a proper location and then registers it.

You can unregister it by adding the /u flag

Microsoft Topic

HackSlash
  • 4,944
  • 2
  • 18
  • 44