0

I've made multiple C# DLLs in MS Visual Studio which I then access from Excel via VBA calls. These work fine on my machine (obviously VS COM registers them for me when compiling as long as I have the right boxes ticked). I also got them working on other machines by searching my registry for any seemingly relevant keys to each of the DLLs, and copying the entries into other machines registries. Obviously that's madness though, so I want I want to make a simple installer so I can install said COM DLLs on other machines easily.

Since I have a windows forms app in there to test all the DLLs, I figured it makes most sense to just make an installer for that app, and the other DLLs should get installed as they're dependencies. Right-clicking, and publishing gives me the setup.exe. I can then install this on the other machines. But the DLLs aren't COM registered on the new machine, so although the test app works, I can't actually use them from Excel/VBA.

What do I need to do? (googling only seems to turn up pretty old stuff that I can't seem to follow with older versions of VS)

  • I'm using the full version of VS 2019.
  • I'm using the basic right-click/properties/publish to make a setup.exe and associated folders.
  • I may get more options by adding an MSIX installer project into the solution? But I've never done that before so when I tried the learning curve of that it seemed a nightmare and wouldn't compile, largely complaining I didn't seem to have an icon of every size under the sun included. Trying to use VS to auto-generate them from 1 image caused VS to crash every time. I can try sitting in paint making them all manually if that's my only option, but it may be pointless if I don't need and MSIX installer anyway.
  • At this point I'm also interested in just COM registering them manually for sanity sake without typing in the registry entries, and can work on the installer later. But as far as I can tell regasm/gacutil aren't on any of these other machines. (I also haven't used that before, so am somewhat confused by which I should use, and if I need to do it for both x86 and 64.)
  • I'm a noob to VS installers, DLLs and the registry (and associated terms), so please try keep it simple. Although obviously I've got as far as making C# DLLs I can call from VBA (once COM registered), and they otherwise work a treat.
Piplodocus
  • 29
  • 2
  • 1
    To register a .NET COM dll, just use "regasm /codebase etc." https://stackoverflow.com/questions/23939699/regasm-when-is-the-codebase-option-applicable. If you want to do it manually you can also use a code like this: https://stackoverflow.com/a/35789844/403671 – Simon Mourier Sep 08 '20 at 14:37
  • Thanks Simon M. I'd already tried copying my Reg entries manually first to this laptop and got access denied issues from VBA. Then followed your first link, followed the top hit of "RegAsm.exe /codebase /tlb {path/name of DLL}". That's now working. I found versions of RegAsm.exe in lots of different folders so used the one in the Windows\WinSxS\x86_regasm_{lots of alphanumeric stuff} folder. Does that mean I've just only done the x86 version? Should I do this using the regasms in the other folders? (This is 32-bit office/Excel/VBA for some reason, so thought I'd start there at least) – Piplodocus Sep 08 '20 at 15:29
  • 1
    Official regasm.exe is in \Windows\Microsoft.NET\\Framework\v4.0.30319 (register in 32bit registry for 32bit clients) or \Windows\Microsoft.NET\\Framework64\v4.0.30319\ (register in 64bit registry for 64bit clients). If you compile your C# dll as "Any Cpu" (recommended), then you can register in both 32 and 64 registries – Simon Mourier Sep 08 '20 at 16:21
  • Depending on the size, you just might want to distribute the files without registering them at all. If you use Isolated COM, you can put the COM information you need in manifests and then you don't have to register the libs. Now, if you want a 3rd party to be able to call into your component, then yes, you need to register it. But, if you only need to consume it in your process, I actually prefer the Isolated COM way."Isolated COM" is also sometimes called "Registration free COM" – Joseph Willcoxson Sep 08 '20 at 21:57

0 Answers0