Sharing component across separate addins

Jul 30, 2015 at 11:49 AM
Edited Jul 30, 2015 at 11:53 AM
We have an existing Excel-DNA add-in with some boilerplate code and a load of core functions available from Excel. Now we want to extend this add-in (rather than modify it) for a select number of users by having a separate add-in that has its own functions but re-uses the boilerplate code from the original add-in.

The boilerplate code contains a singleton (not my design) which I would like to access from both add-ins. Unfortunately because these add-ins live in separate AppDomains two separate singletons get created (one in each AppDomain). I'm happy to move the boilerplate code out of the original add-in and put it in a separate library, if that makes things easier.

What is best way for two add-ins to use the same instance of a library? Is it possible to run the add-ins in the same AppDomain?
Coordinator
Jul 30, 2015 at 1:39 PM
Hi,

The add-ins can't run in the same AppDomain.

You should be able to combine the assemblies (the original add-ins .dll library and the new assemblies) into a single add-in without too much difficulty.
Your .dna file can have multiple <ExternalLibrary ...> tags and these can point to different .dll assemblies or .dna files. So composing into a combined add-in should be straight-forward.

-Govert
Aug 3, 2015 at 6:10 PM
Govert,

Yep, using ExternalLibraries is a much neater solution.

Many thanks.