Shared static classes between AppDomains in loaded library code
- by Christian Stewart
I'm working on a program in which I want to do something similar to what the Photon Server system does:
Offer a common "API" class library, which contains common data classes, enumerations, and interfaces for working with the host program.
Have client programs (class libraries) reference this DLL and implement interfaces listed within it.
Have the "host" application load built DLL client libraries into separate AppDomains and reference the interfaces that lie within to have polymorphic client code from within a dll file.
I have something like this worked out: a class library that contains common code, but I've run into the following question
How should I handle static classes? Should I add a method that is called by the host program to synchronize data? How do I keep a static class the same between AppDomains? Should I discard these classes in favor of better interfaces between the code levels?
And in general, how do I share data between these loaded AppDomains?