2

这项工作适用于我正在转移到这个应用程序中的另一个应用程序。我已经被困在这里几个小时了,谷歌没有太多的 MEF。System.ComponentModel.Composition.dll 已导入,是的。但仍然无法摆脱这个错误。

我有这个包括:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.ComponentModel.Composition;
using JSNet;

受影响的代码:

var catalog = new AggregatingComposablePartCatalog();
var mainAssemblyCatalog = new AttributedAssemblyPartCatalog(this.GetType().Assembly);
var jsNetCatalog = new AttributedAssemblyPartCatalog(typeof(Effect).Assembly);            
//var addInEffects = new DirectoryPartCatalog("Effects"); 

catalog.Catalogs.Add(mainAssemblyCatalog);
catalog.Catalogs.Add(jsNetCatalog);
//catalog.Catalogs.Add(addInEffects);
var container = new CompositionContainer(catalog);

错误:

Error 1: The type or namespace name 'AggregatingComposablePartCatalog' could not be found (are you missing a using directive or an assembly reference?) 

Error 2: The type or namespace name 'AttributedAssemblyPartCatalog' could not be found (are you missing a using directive or an assembly reference?)    

Error 3: The type or namespace name 'AttributedAssemblyPartCatalog' could not be found (are you missing a using directive or an assembly reference?)    

Error 4: The type or namespace name 'CompositionContainer' could not be found (are you missing a using directive or an assembly reference?)
4

1 回答 1

7

检查您的应用的框架版本是否设置为客户端配置文件。如果是,这是你的问题。您引用的程序集可能不是针对客户端配置文件。将其更改为 .NET 4.0(不是 4.0 客户端配置文件)

于 2012-04-07T03:08:10.990 回答