Avoiding Application Domain misery
This is a short but important subject (assuming you’re using Addin Express).
There are 3 types of Addin Express module used in GeodesiX:
- GeodesiXEXL. Used to handle Excel events.
- GeodesiXRTD. The RTD components
- GeodesiXUDF. The UDFs
The first two are loaded in the default Application Domain, the 3rd gets loaded when needed. If you let Excel load it, it gets loaded into a separate Application Domain, which means that the Common singleton gets created a second time and the modules are unable to share the cache.
We avoid this problem by pre-emptively calling Geocode when the GeodesiXEXL is initially loaded #26#. This forces the addin to load in the default domain.
I thought I was smarter and tried to find a way to share data amongst AppDomains. It’s not possible.
Update 6 April 2011: Cross-App-Domain data sharing is possible, by passing MarshalByRefObjects around with IPC. I have a working solution, but it’s not as stable as I would like. When it is, I’ll write it up on my blog.