简体   繁体   English

在不重新启动 web 应用程序的情况下加载 MEF 插件

[英]Loading MEF plugins without restarting web application

I am developing a web application in .NET that uses in the backend (web api) plugins that are loaded via MEF.我正在 .NET 中开发一个 web 应用程序,该应用程序在通过 MEF 加载的后端(web api)插件中使用。 In Web API I use Autofac DI and MEF to load plugins.在 Web API 中,我使用 Autofac DI 和 MEF 加载插件。 The problem I encountered is how to replace plugins in production without having to restart the web application (Azure) or IIS pool.我遇到的问题是如何在生产中替换插件而无需重新启动 web 应用程序 (Azure) 或 IIS 池。 I even planned to host each plugin as one web service so that the application does not depend on plugins.我什至计划将每个插件托管为一个 web 服务,以便应用程序不依赖插件。

Recomposition is the answer. 重组就是答案。

In short:简而言之:

  • Mark your plugin import with allow-recomposition使用 allow-recomposition 标记您的插件导入
  • MEF will trigger re-import every time new plugin appears, or existing dissapear每次出现新插件或现有插件消失时,MEF 都会触发重新导入

More samples you'll find here:您可以在此处找到更多示例:

https://qube7.com/guides/recomposition.html https://qube7.com/guides/recomposition.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM