I'm trying to enable the capability of using plugins in my WPF application. As far as my understanding goes, I need (well, not need, but it's suggested) to create an additional app domain.
For this, I'm doing the following on startup in my App.xaml.cs:
private void LoadPlugins()
{
// Create and polish plugin app domain
AppDomain pluginAppDomain = AppDomain.CreateDomain("MyProject Plugin Container", null);
pluginAppDomain.UnhandledException += PluginAppDomain_UnhandledException;
//TODO: Load plugins from dlls
}
private void PluginAppDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
Logger.FatalException("PluginAppDomain", e.ExceptionObject as Exception);
}
But attaching the UnhandledException event fails with exception:
Type 'MyProject.App' in assembly 'MyProject, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1337' is not marked as serializable.
What could be the issue?