E
Ethan Post
Is it possible to implement a control that can be loaded into, and later
unloaded from current the process when it is no longer needed? I've been
able to do this with other classes by subclassing MarshalByRefObject,
putting it in it's own assembly, and loading it into its own AppDomain
(which can later be unloaded). But as far as I can tell, this isn't as easy
with a System.Windows.Form.Control descendant (even though they descend from
MarshalByRefObject).
The first problem I've run into is that as soon as I try to use the control
(which was created in a different AppDomain), I get a SerializationException
because the ControlCollection class (of the parent) is not a descendant of
MarshalByRefObject (or serializable). Apparantly, controls need to
reference that collection in some way, when they are added to the parent
(which is in the original AppDomain in this situation).
So my question is, is there some way to implement an unloadable control,
where all it's code is in an assembly that can be loaded-into/unloaded-from
the process? There may be workarounds, like just making the code behind the
control's events unloadable, and not the control itself. But for my
purposes, the control wouldn't be generic enough for something like that. A
good analagy would be a user control for implementing a propery sheet.
Any ideas?
-Ethan
unloaded from current the process when it is no longer needed? I've been
able to do this with other classes by subclassing MarshalByRefObject,
putting it in it's own assembly, and loading it into its own AppDomain
(which can later be unloaded). But as far as I can tell, this isn't as easy
with a System.Windows.Form.Control descendant (even though they descend from
MarshalByRefObject).
The first problem I've run into is that as soon as I try to use the control
(which was created in a different AppDomain), I get a SerializationException
because the ControlCollection class (of the parent) is not a descendant of
MarshalByRefObject (or serializable). Apparantly, controls need to
reference that collection in some way, when they are added to the parent
(which is in the original AppDomain in this situation).
So my question is, is there some way to implement an unloadable control,
where all it's code is in an assembly that can be loaded-into/unloaded-from
the process? There may be workarounds, like just making the code behind the
control's events unloadable, and not the control itself. But for my
purposes, the control wouldn't be generic enough for something like that. A
good analagy would be a user control for implementing a propery sheet.
Any ideas?
-Ethan