这是我的应用程序文件夹的样子:
Application:
+ App.exe
+ App.exe.config
Application/Plugins:
+ Plugin1 (folder)
Application/Plugins/Plugin1:
+ Plugin1.dll
+ SomeDll.dll
所以主应用程序 App.exe 寻找插件文件夹并将 {PluginName}.dll 加载到内存中以运行它。该插件通常使用它自己的必须加载的依赖程序集(如 SomeDll.dll)。看起来它有时会制造严重的麻烦。我收到异常,例如无法找到依赖程序集的依赖程序集,我不知道为什么。
例如,我的插件必须加载大量额外的 dll,因为插件运行 OwinSelfHost 服务。
所以它必须加载例如:
System.Web.Http.Owin
Owin
Microsoft.Owin
Microsoft.Owin.Host.HttpListener
Microsoft.Owin.Hosting
当加载Microsoft.Owin.Hosting然后抛出无法加载Microsoft.Owin 的异常
异常看起来像:
Could not load file or assembly 'Microsoft.Owin, Version=2.0.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of it's dependencies. File not found.