tags:

views:

64

answers:

1

I have created a c# 2.0 WinForm application which loads dlls, searches for an interface, and then loads the interface as a plugin. I am loading the plugins in the same appdomain as the main application because they have a GUI which I am directly loading into the application as a tab item.

I would like to load them in their own app domain, but do not think it is possible because of the GUI. I would also like to monitor them to tell if they are not responsive and unload them.

Is this possible? If I upgrade to WPF are things any simpler.

+1  A: 

If you allow the plugins to create their own WinForms UI controls they will have to run on the same thread as your main UI, thus you cannot isolate the plugins in their own appdomain.

What you could do is define a non-UI abstraction layer between the host and the plugins such that plugins only message the host what type of UI they require. The host is then responsible for creating the UI controls and relay input to the plugins. This enables the plugin instances to live in a separate appdomain.

Update: with WPF and System.AddIn (aka MAF) it is possible to do UI cross appdomains. I would read up on some opinions on MAF before going that route.

Peter Lillevold
No, it is not true for WPF. http://blogs.msdn.com/b/clraddins/archive/2007/08/06/appdomain-isolated-wpf-add-ins-jesse-kaplan.aspx
Lex Li
@Lex Li: thanks for the heads up!
Peter Lillevold