.NET Core(或 ASP.NET 5)中是否有 MEF 的替代品 [英] Is there a replacement for MEF in .NET Core (or ASP.NET 5)

查看:31
本文介绍了.NET Core(或 ASP.NET 5)中是否有 MEF 的替代品的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们知道 .NET Core(开源组件)只是完整 .NET Framework 的一个子集,并且 ASP.NET 5(和 MVC 6)是基于 .NET Core 构建的.这是否意味着托管可扩展性框架 (MEF) 在 ASP.NET 5 中不可用?

We know that .NET Core (the open-source components) are only a subset of the full .NET Framework, and that ASP.NET 5 (and MVC 6) is built on .NET Core. Does this mean that Managed Extensibility Framework (MEF) is not available in ASP.NET 5?

如果是,是否有任何替代 .NET Core 中可用的动态可扩展性?

If so, is there any replacement for dynamic extensibility available in .NET Core?

我有许多使用 MEF 动态加载插件和外部集成的应用程序,如果它们仅仅因为使用 MEF 而被锁定在 .NET Framework 中,那将是一个遗憾.

I have a number of applications that use MEF to dynamically load plugins and external integrations and it would be a pity if they were locked into the .NET Framework just because they use MEF.

推荐答案

现有的 NuGet 包应该可以工作.它是可移植的,而 .NET Core 是可移植 API 表面的向后兼容演变.ASP.NET Core 不会自动安装它,但是因为该包没有明确说明它与 .NET Core 兼容.

The existing NuGet package should work. It's portable, and .NET Core is a backward-compatible evolution of the portable API surface. ASP.NET Core won't automatically install it, however because the package doesn't explicitly say that it's compatible with .NET Core.

要安装该软件包,您需要将 imports 部分添加到您的 project.json:

To install the package, you'll need to add an imports section to your project.json:

{
  "dependencies": {
    "Microsoft.Composition": "1.0.30"
  },
  "frameworks": {
    "netcoreapp1.0": {
      "imports": "portable-net45+win8"
    }
  }
}

这篇关于.NET Core(或 ASP.NET 5)中是否有 MEF 的替代品的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆