我正在尝试启用在我的 WPF 应用程序中使用插件的功能。据我了解,我需要(嗯,不需要,但建议)创建一个额外的应用程序域。
为此,我在 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);
}
但附加 UnhandledException 事件失败并出现异常:
在程序集“MyProject,Version=1.0.0.0,Culture=neutral,PublicKeyToken=1337”中键入“MyProject.App”未标记为可序列化。
可能是什么问题?