3

I see that v2.0: 75% there post mentions Autocad and there is an AutoCADApp.cs file, but I can't seem to find a reference for using Rubberduck outside of Office, under some random host application. There is this Adding a new Host Application to Rubberduck but that is already done for Autocad.

Using Rubberduck under Autocad requires building from source? Or is there a procedure to use the already installed release package?

Mathieu Guindon
  • 69,817
  • 8
  • 107
  • 235
Nicu Tofan
  • 1,052
  • 14
  • 34

1 Answers1

4

Disclaimer: I'm heavily involved with the Rubberduck project.

Likely you're simply missing the registry keys for AutoCAD's VBE to notice your ducky.

Rubberduck's installer searches for the bitness of your Microsoft Office install, and then registers itself using that bitness.

So if you have 32-bit Office and 32-bit CAD, you're all set. Ditto with 64-bit Office and 64-bit CAD. In your case you probably have 32-bit Office but 64-bit CAD, and so there's no registry key to tell a 64-bit VBE to load an add-in called Rubberduck.

You can run the PowerShell script you found in the project's wiki (it creates both 32 and 64 bit addin keys), or create the missing HKCU registry key manually, but then the add-in will be seen, but still won't load, because the COM interop stuff was registered under 32-bit nodes, and CAD will expect RD to be registered under 64-bit nodes. To register for 64-bit, you'll have to run (as administrator) a 64-bit regasm.exe command, as described in the "troubleshooting 'add-in could not be loaded'" section of the installer wiki:

Note: the bitness of your OS is irrelevant.

Bring up an administrative command prompt (cmd.exe), and execute one of the following commands:

32-bit host:

c:\windows\microsoft.net\framework\v4.0.30319\regasm.exe "(path to install folder)\rubberduck.dll" /codebase /tlb

64-bit host:

c:\windows\microsoft.net\framework64\v4.0.30319\regasm.exe "(path to install folder)\rubberduck.dll" /codebase /tlb

Note that these registration steps are required even if you build the addin yourself from the source code.

Mathieu Guindon
  • 69,817
  • 8
  • 107
  • 235
  • Using Autocad 2015 here; running the commands and adding the install path to trusted paths does not seem to help, and by that I mean that the menu does not show up in VBA ide. – Nicu Tofan Aug 04 '17 at 15:08
  • `AddIns64` was missing (but `AddIns64` was present) and I created by hand that key. It complained that `Rubberduck could not be loaded` so i run the register routines from a command prompt (admin). Now I have [following exception](https://pastebin.com/eW1uivM8). – Nicu Tofan Aug 04 '17 at 17:34
  • The assumption here is that the same `rubberduck.dll` is to be used with both 32-bit and 64-bit commands (`(path to install folder)` is the same in the two invocations above). – Nicu Tofan Aug 04 '17 at 17:38
  • Ah, crap. I'm not sure which version of AutoCAD we're using interop assembly for... definitely some progress was made though - at least it's *trying* to load it. I *think* you can try overwriting the interop .dll's we're packaging with the one you have installed (might screw up the RD install though). Pretty sure it's just a version thing. We need to figure out a better way to do this. – Mathieu Guindon Aug 04 '17 at 17:59
  • If you fork the project and build RD (make sure you un-register with `regasm.exe (path)/u` to undo the manual x64 registration, and then uninstall to clean up the installer-created keys first), replacing the CAD interop assemblies with your own, I think you'll have a cleaner experience (still need to re-create the keys and register your build [once - no need to register everytime you rebuild]) than if you overwrite the dll's on the compiled solution. Sorry it's such a pain... Joys of COM interop! – Mathieu Guindon Aug 04 '17 at 18:08