Recently I have been receiving a fair number of questions about sharing data across add-ins. The problem for add-in developers is we don’t control the instantiation or reference to our implementation of the add-in interfaces. This means when we need to share data between add-ins it’s difficult to do so because we don’t have any references to use. There are two possible solutions to this problem, the first is we can define all data we need to share as public static in the containing class, the second solution is to utilize the singleton design pattern.
The first solution is what I consider a “quick and dirty” solution, it gets the job done but is not very nice. I generally use this solution when I’m building out a very quick sample or proof of concept and don’t have a lot of data that I need to share. A classic example of this is assigning a public static variable to the IAutomationContext reference supplied when implementing an IAutomationClient.
The second solution is a much more eloquent and scalable approach. When building a complex production quality add-in this is the approach that should be followed. Generally what I do is to make a class that implements the singleton design pattern and then define properties for all the data that will need to be shared across the add-ins. Microsoft has a good article on implementing the singleton design pattern in C#. I recommend the article be read by anyone looking to follow this approach.
Once you have the singleton implemented it will become very easy to share data across your different add-ins. What other design patterns are you using in your add-in or would you like to see us use in our samples?

Dear admin, thnx for sharing this blog post. I found it wonderful. Best regards, Victoria…
I tried the singleton solution to share data across Add-Ins, but it does not work if the AddIns are uploaded separately using the AddIn Manager. I created a custom class that I’ve made Singleton. You said something about IAutomationClient in your post. Do I need to extend IAutomationClient and make it a singleton, or any custom class will do?
Thanks,
Cristina
You do not need to implement the IAutomationClient in your singleton class. It will also work across add-ins that are uploaded separately in the add-in manager. You might want to visit the RightNow Developer community and post your question or code there to get some more assistance but it should work as I describe.