-1

I have developed a new (small) class using .Net Framework (VB.NET) on Visual Studio and did a reference on VBA-Excel to execute a task. It worked fine on my machine, so the real problem here is to deploy this class on the client's machine.

When I did the build on Visual Studio, I've selected "Register for COM Interop", so it was created a .dll and .tbs file. I thought I could just use a reference on VBA to these files and everything would work fine, but it's not that simple. I have to register the dll on the system before I can use it, and the Visual Studio did that automatically on the build.

The question is, how can I make a common setup installer to only install those dll and tbl files into anyone's machine? The files must remain on a known folder so I can reference them on the VBA, but the windows register must know they exist!

What do I know so far:

  • On the build, Visual Studio uses Regasm.exe to register the dll; I could use a bat file to call regasm.exe but it is not a option because I would have to make a reference to it and each client could have different .Net Framework versions, so I wouldn't be able to know the full path of it.

  • regsvr32.exe won't work it either, since we need Admin Rights, and
    the clients don't have it.

  • I could use ClickOnce, but it's a Class Library so the Publish option does not exist.

Here I have some references, but I couldn't find a good solution yet.

https://www.red-gate.com/simple-talk/dotnet/visual-studio/build-and-deploy-a-.net-com-assembly/

https://social.msdn.microsoft.com/Forums/windows/en-US/70f5558c-cf53-4bc0-b3ea-435b6f5b3956/how-to-get-setup-project-to-register-assembly-for-com-interop?forum=winformssetup

https://social.msdn.microsoft.com/Forums/en-US/47d6dc58-37ce-4a34-9524-20dc1c1ffd90/how-to-use-clickonce-deployment-technology-for-class-library-project?forum=winformssetup

UPDATE 1

It seems that the only way of installing in the register is through regasm.exe or regsvr32, and both of 'em need elevated command prompt (with admin rights), something the clients do not have.

I guess the solution is to use registration-free activation of COM components, that it wouldn’t require updating Registry or placing assemblies in GAC. Here's the reference:

Is it possible to register a .NET assembly for COM interop without adding registry entries?

UPDATE 2

I've found this answer and I can feel that I'm real close to a solution:

Registering .Net COM DLLs without Admin rights / regasm

The thing is, the class that I've developed is using another class, which is PdfSharp. When I unregister the dll and try to register again (through regasm.exe), my VBA macro gives an error not when I'm creating the object, but when I'm executing a funtion of the class, saying that the PdfSharp couldn't be found.

The solution of this question doesn't say anything about using 3rd party library, and I thought that my .dll would bring the pdfsharp.dll as well.

Any ideias? I'm real close to solve this.

  • I suggest you include your .net framework version .dll into the install directory and run RegAsm to register it –  Nov 28 '17 at 15:42
  • Hello, peakpeak! Use RegAsm in prompt is not an option, since I dont know the version of the client's .Net Framework to get its RegAsm full path. I'm looking for a way to do this via setup, somehow. A simple Setup that install a DLL, created via Visual Studio – Rafael Pacheco Nov 28 '17 at 17:02
  • Correction: The file extension is not tbs, but .tlb (Type Library) – Rafael Pacheco Nov 28 '17 at 17:04
  • Check this blog: http://www.hanselman.com/blog/NETVersioningAndMultiTargetingNET45IsAnInplaceUpgradeToNET40.aspx –  Nov 29 '17 at 06:59
  • It seems a good workaround. I'll try to create a new project (Console App, maybe... one that I can publish with ClickOnce) and include my class in there, with the "Register for COM Interop" checked, hoping that the registration of the dll take place at install time, not build time. I'll try that, and set the results here later. Thank you! – Rafael Pacheco Nov 29 '17 at 12:30
  • More info here: https://stackoverflow.com/questions/3534600/what-does-register-for-com-interop-actually-do –  Nov 29 '17 at 15:30

2 Answers2

0

Have you tried using Install Shield Limited Edition to package your application? It's free.

Mike Bruno
  • 600
  • 2
  • 9
  • 26
  • I use the Visual Studio 2017, and it seems that in this version the Install Shield LE is no long available =/ – Rafael Pacheco Nov 28 '17 at 23:20
  • @RafaelPacheco you have to manually install the plugin in 2015 and newer https://marketplace.visualstudio.com/items?itemName=VisualStudioProductTeam.MicrosoftVisualStudio2017InstallerProjects – Scott Chamberlain Nov 29 '17 at 17:19
  • I've installed the plugin but I couldn't make it work. I tried to add the Assembly to a wizard setup, but it just unpacked the file that I added, and also made a request of Admin Rights, something that I have to avoid. Can you assist me on how I could make the installation of the DLL through a setup wizard? – Rafael Pacheco Dec 01 '17 at 00:56
0

I gave up trying to install the DLL on machines that haven't Admin Rights, so I've developed a Console app on Visual Studio and run it via Shell command on VBA, and it worked like a charm.

I'll set this as the right answer since it solved my problem, but I couldn't find a way to deploy a dll via installer on other machines.