P
Pete Davis
I'm confused about what precisely the limitations are on loading plugins in
separate app domains. In all my previous apps that supported plugins, I've
loaded them into the same domain as the app, but I've just started playing
around with separate AppDomains and I'm finding that I'm not having problems
where I expected I would, so maybe someone can help me understand a bit
better.
I've read that objects instantiated in separate AppDomains need to derive
from MarshalByRefObject. Why is this?
I have an IPlugin interface. I have a class (not derived from
MarshalByRefObject) in an assembly that implements the IPlugin interface.
I've done the following to create an instance of the object (path is the
path and filename of the assembly with the class, and typeFullName is the
FullName of the Type of the object):
AppDomain domain = AppDomain.CreateDomain("PluginTest");
Assembly asm = domain.Load(path);
IPlugin plugin = asm.CreateInstance(typeFullName) as IPlugin;
The object appears to instantiate fine and I called two different
properties, one that returned a string and one that returned a Guid. Both
returned the correct objects.
So I'm confused. Why do I need to derive from MarshalByRefObject?
Or have I done something wrong that somehow created the object in my primary
AppDomain?
I'm not really sure I need the separate AppDomain stuff for what I'm doing,
but thought I'd play with it while I'm creating this new plugin manager to
see what all the fuss is about.
Pete
separate app domains. In all my previous apps that supported plugins, I've
loaded them into the same domain as the app, but I've just started playing
around with separate AppDomains and I'm finding that I'm not having problems
where I expected I would, so maybe someone can help me understand a bit
better.
I've read that objects instantiated in separate AppDomains need to derive
from MarshalByRefObject. Why is this?
I have an IPlugin interface. I have a class (not derived from
MarshalByRefObject) in an assembly that implements the IPlugin interface.
I've done the following to create an instance of the object (path is the
path and filename of the assembly with the class, and typeFullName is the
FullName of the Type of the object):
AppDomain domain = AppDomain.CreateDomain("PluginTest");
Assembly asm = domain.Load(path);
IPlugin plugin = asm.CreateInstance(typeFullName) as IPlugin;
The object appears to instantiate fine and I called two different
properties, one that returned a string and one that returned a Guid. Both
returned the correct objects.
So I'm confused. Why do I need to derive from MarshalByRefObject?
Or have I done something wrong that somehow created the object in my primary
AppDomain?
I'm not really sure I need the separate AppDomain stuff for what I'm doing,
but thought I'd play with it while I'm creating this new plugin manager to
see what all the fuss is about.
Pete