Skip to content

Adding a new Host Application to Rubberduck

ThunderFrame edited this page Aug 6, 2017 · 3 revisions

Rubberduck needs the Primary Interop Assemblies to run Unit-Tests. As such these Assemblies (also shortened to PIAs) are necessary for only the Unit-Testing feature.

To run the Unit-Tests Rubberduck accesses the Application.Run method, calling the tests by their name.
For other Hosts than Office the names of the method may differ. This means we need a way to call into these PIAs.

Generating the PIA

For that we should first have a PIA. This means we'll generate ourselves one.
The linked msdn article goes into detail, but in short you'll run the following command:

tlbimp HostAppCOM.tlb /out:HostApp.Interop.dll

Referencing the PIA

Before we can use the PIA now we need to reference it in Rubberduck. When you open the Rubberduck Solution in Visual Studio you will see something along the following:

Rubberduck Solution's references in Visual Studio. Taken from http://chat.stackexchange.com/transcript/message/18984962#18984962

You'll usually just have to right-click and use add after dropping the generated PIA in the libs directory

Using the Referenced PIA

The next step is the last one (it's basically two steps in one, but eh). You need to implement a new IHostApplication by extending HostApplicationBase. The only remaining step to be done here is to give the HostApplication it's name and specify how Rubberduck can call things through the PIA.

Finally you need to add a case for your application in the HostApplicationExtensions, the same way all other cases work:

                case "YourApplication":
                    return new YourApplicationApp();
Clone this wiki locally