views:

65

answers:

1

Hi.

Is there a way to allow an instance of a class from a dynamically loaded assembly to show a form?

I have this plugin system which loads assemblies in separate domains (for unloading them as needed). These assemblies might have settings, and I was hoping I could have each assembly present a form to the end user to allow for editing them. Each extension in an assembly needs to implement a special interface just for this. However, on showing the form from my plugin manager class, I get an exception that the Form class isn't serializable. Apart from deriving from Form and implementing ISerializable myself, is there another way to do this?

Tx for any hints, tips, and (hopefully :D) solutions! ...Arjan...

A: 

The serialization issue is because the Form class isn't Marshal by reference and you're trying to invoke a method on the class across domains. If the only form they need to show is for user settings, you might be better of defining some sort of "settings" class that is passed between the plugins.

Paul Alexander
Paul,thanks for your answer. But although this might be a solution, I have to counter for the fact that those forms might contain logic which is not easily transferred using a Settings class. The extensions/plugins are not totally within my control, and can be developed by third parties...
Arjan de Haan
The other option then is to signal to the plugin in the other AppDomain that it needs to show the form and it never passes a reference to that form back to the calling domain. It can pass a DialogResult to indicate the success or failure of the form.
Paul Alexander