类型或命名空间名称'';未能找到(是否缺少using指令或程序集引用?)

本文关键字:using 指令 程序集 引用 是否 命名空间 类型 | 更新日期: 2023-09-27 18:30:13

这项工作对于我正在转移到这个应用程序中的另一个应用程序来说很好。我已经被困在这里几个小时了,谷歌没有太多的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?)

类型或命名空间名称'';未能找到(是否缺少using指令或程序集引用?)

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