3

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.

Telavian
  • 3,752
  • 6
  • 36
  • 60
  • Could you go into a little more detail about what you define as unresponsive. If the plugins are "executing" on the main application thread, then by definition, your whole application would be unresponsive. What are the plugins doing? – Tim Lloyd May 29 '10 at 19:21
  • Basically if a plugin is poorly written or has problems loading, I would like to know that and not load it next time. – Telavian May 31 '10 at 01:18

1 Answers1

1

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.

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Peter Lillevold
  • 33,668
  • 7
  • 97
  • 131
  • 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 May 30 '10 at 00:25