如何便携式类库使用MEF? [英] How to use MEF in Portable class library?

查看:251
本文介绍了如何便携式类库使用MEF?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经便携式类库针对.NET 4.5和Windows Store应用。 根据MSDN这个设置应该提供MEF 但事实并非如此。命名空间 System.ComponentModel.Composition 不可用(我甚至试过 System.Composition ,但没有运气)。它也无法使用 Microsoft.Composition 的NuGet包,它与Windows Store应用工作。

错误安装时,的NuGet版本

  

Microsoft.Composition 1.0.15已安装。无法安装   包'Microsoft.Composition 1.0.15。

     

您要安装此   包成针对一个项目   .NETPortable,版本= V4.5,外形= Profile7',但不包   包含有与兼容的任何程序集引用   框架。欲了解更多信息,请联系包的作者。

解决方案

您需要手动添加引用从包中的二进制文件。我通常安装包到特定于平台的项目(如.NET框架4.5),那么只需手动便携式引用。

这将是固定接下来的NuGet的版本(2.1),我们将更新MEF包与之不谋而合。

I have portable class library targeted to .NET 4.5 and Windows Store App. According to MSDN this setting should offer MEF but it does not. Namespace System.ComponentModel.Composition is not available (I even tried System.Composition but no luck). It is also not possible to use Microsoft.Composition NuGet package which works with Windows Store App.

The error when installing NuGet version is:

'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.

解决方案

You need to manually add a reference to the binary from the package. I typically install the package to a platform-specific project (such as .NET Framework 4.5) then just manually reference from portable.

This will be fixed next version of NuGet (2.1) and we'll update the MEF package to coincide with it.

这篇关于如何便携式类库使用MEF?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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