.net - 如何在可移植类库中使用 MEF?

标签 .net mef visual-studio-2012 portable-class-library windows-store-apps

我有针对 .NET 4.5 和 Windows Store App 的可移植类库。 According to MSDN this setting should offer MEF但事实并非如此。命名空间 System.ComponentModel.Composition不可用(我什至尝试过 System.Composition 但没有运气)。也不能使用 Microsoft.Composition与 Windows Store 应用程序配合使用的 NuGet 包。

安装时报错NuGet version是:

'Microsoft.Composition 1.0.15' already installed. Could not install package 'Microsoft.Composition 1.0.15'.

You are trying to install this package into a project that targets '.NETPortable,Version=v4.5,Profile=Profile7', but the package does not contain any assembly references that are compatible with that framework. For more information, contact the package author.

最佳答案

您需要从包中手动添加对二进制文件的引用。我通常将包安装到特定于平台的项目(例如 .NET Framework 4.5),然后从可移植的手动引用。

这将在 NuGet (2.1) 的下一个版本中修复,我们将更新 MEF 包以与它一致。

关于.net - 如何在可移植类库中使用 MEF?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12483686/

相关文章:

mef - 使用 MEF 导入由 IronPython 或其他 DLR 语言导出的组件?

c++ - Visual Studio npcc64_60.dll 陷阱?

c# - .NET 4 中的 StackOverflowException

c# - 使用 Moq 在类上模拟一个方法而不是整个类?

c# - 如何使用私有(private) setter 将模拟接口(interface)分配给属性以进行单元测试?

c# - MEF 加载和卸载特定插件?

c - 尝试从 C 代码获取 Windows 版本

visual-studio-2012 - 我想用MD5 Class做一些加密工作,但是找不到?

c# - 如何在 C# .Net 核心的工厂设计模式中使用反射

.net - 如何控制触发事件处理程序的顺序?