미리 도움을 주셔서 감사합니다. 나는 다음과 같은 수출 부분이 있습니다MEF Composition .NET 4.0
[Export (typeof(INewComponent))] // orignally tried just [Export} here and importing NewComponent below
public class NewComponent : INewComponent
{
// does stuff including an import
}
콘솔 테스트 프로그램이 수입을 위 :
: 조성은 이러한 CompositionExceptions 실패public class Program
{
[Import] // have tried variations on importing "NewComponent NewComponent" etc
public INewComponent NewComponent
{
get;
set;
}
public static void Main(string[] args)
{
var p = new Program();
var catalog = new AssemblyCatalog(typeof(Program).Assembly);
var container = new CompositionContainer(catalog);
container.ComposeParts(p);
}
는 (나는 :) 유죄를 보호하기 위해 네임 스페이스를 제거)
1) '((exportDefinition.ContractName == "INewComponent") 및(exportDefinition)과 일치하는 유효한 내보내기가 없습니다. .Metadata.ContainsKey ("ExportTypeIdentity") AndAlso "INewComponent".Equals (exportDefinition.Metadata.get_Item ("ExportTypeIdentity")))) ', 잘못된 내보내기가 거부되었을 수 있습니다.
이 같은 메인 프로그램에서 구성을 할 경우 구성이 성공적으로 작동합니다
public class Program
{
public static void Main(string[] args)
{
INewComponent newComponent = new NewComponent();
var catalog = new AssemblyCatalog(typeof(Program).Assembly);
var container = new CompositionContainer(catalog);
container.ComposeParts(newComponent);
}
}
이
짐 감사합니다. 네, NewComponent가 DLL에 있었고 위의 트릭을했습니다. 다시 돌아가서 MEF에서 Block의 원본 MSDN 기사를 다시 읽어야합니다. h2에 대한 블로그의 Thx는 Visual MEFX와 함께합니다. 완전한. –