type or namespace name '…' could not be found (are you missing a using directive or an assembly reference?)

大城市里の小女人 提交于 2019-12-24 01:18:35

问题


This work's fine for another app that I'm transferring into this one. I've been stuck here for hours and google does not have much for MEF. the System.ComponentModel.Composition.dll is imported, yes. But still cannot get rid of this error.

I have this for my includes:

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

Affected code:

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);

Errors:

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?)

回答1:


Check if your app's framework version is set to Client Profile. If it is, this is your problem. The assembly you're referencing likely isn't targeting Client Profile. Change it to .NET 4.0 (not 4.0 Client Profile)



来源:https://stackoverflow.com/questions/10051382/type-or-namespace-name-could-not-be-found-are-you-missing-a-using-directi

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!