开发者

Mixing MEF parts targetting .NET 3.5 with an application targetting .NET 4.0

开发者 https://www.devze.com 2022-12-14 15:59 出处:网络
The Managed Extensibility Framework is both a stand-alone project (currently targetting .NET 3.5) and part of the .NET 4.0 framework.

The Managed Extensibility Framework is both a stand-alone project (currently targetting .NET 3.5) and part of the .NET 4.0 framework.

Suppose I create assemblies targetting .NET 3.5 that contain MEF parts. These assemblies will reference the stand-alone version of System.ComponentModel.Composition.dll开发者_JAVA百科.

Now suppose I create a MEF-enabled application targetting .NET 4.0. This application will reference the System.ComponentModel.Composition.dll that comes with the .NET 4.0 framework. Will I be able to use the aforementioned MEF parts in this application?


Unfortunately this will not work because you the 3.5 version of System.ComponentModel.Composition.dll can only be produced by building the codeplex drop and isn't signed by the same key as the official 4.0 version so the CLR will load both assemblies and treat the attributes as two different attributes. So assuming the application is using the .Net 4.0 version of System.ComponentModel.Compsition.dll and constructs the Catalog/Container it will only find parts that were marked with attributes from the .Net 4.0 version.

0

精彩评论

暂无评论...
验证码 换一张
取 消