AppDomains and Dynamic un/re-loading

G

Guest

I'm currently developing a client that connects to a server and exchanges
data with the server back and forth. The client retains the data in specified
classes depending on what was received. While adding a plugin type API I ran
into the following problem:

I want users to be able to dynamically un/re-load their plugins as needed,
but without having to restart the client. Searching quickly pointed me to
articles on AppDomains. However none of them seem to explain how I can allow
these plugins to access data that in being retained by the client in its
classes.

So basicly:

I have a client with info.
I have plugins that need to access this from the plugin while maintaining
the ability to dynamically un/re-load the plugin.

Any ideas or articles that could explain how to go about this?
 
J

Jon Skeet [C# MVP]

ASayre said:
I'm currently developing a client that connects to a server and exchanges
data with the server back and forth. The client retains the data in specified
classes depending on what was received. While adding a plugin type API I ran
into the following problem:

I want users to be able to dynamically un/re-load their plugins as needed,
but without having to restart the client. Searching quickly pointed me to
articles on AppDomains. However none of them seem to explain how I can allow
these plugins to access data that in being retained by the client in its
classes.

So basicly:

I have a client with info.
I have plugins that need to access this from the plugin while maintaining
the ability to dynamically un/re-load the plugin.

Any ideas or articles that could explain how to go about this?

Welcome to the wonderful world of marshalling :)

This is a tricky topic, with various options. If you're able to make
everything you the plugins need derive from MarshalByRefObject at some
point, it's probably not *too* bad - otherwise you'll need to be very
careful in exactly how things are marshalled when. Alternatively, you
might want to try to load as much as possible into the temporary
AppDomain, leaving your "main" AppDomain as a pretty empty shell which
just does enough to get the other AppDomains up and running, and handle
unloading and reloading.

I don't have any articles to hand on how best to do this, but you
should probably have a look at the NUnit source code
(http://www.nunit.org) as that does exactly the same kind of thing as
it sounds like you need to.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top