MEFGetExports使用AllowMultiple=True时不返回任何内容我正在尝试使用MEF获取有关类及其使用方法的一些信息。我正在使用元数据选项来尝试实现这一点。我的界面和属性如下所示:publicinterfaceIMyInterface{}publicinterfaceIMyInterfaceInfo{TypeSomeProperty1{get;}双SomeProperty2{得到;}字符串SomeProperty3{得到;}}[元数据属性][AttributeUsage(AttributeTargets.Class,AllowMultiple=true)]publicclassExportMyInterfaceAttribute:ExportAttribute,IMyInterfaceInfo{publicExportMyInterfaceAttribute(TypesomeProperty1,doublesomeProperty2,stringsomeProperty3):base(typeof(IMyInterface)){SomeProperty1=someProperty1;一些属性2=一些属性2;一些属性3=一些属性3;}publicTypeSomeProperty1{get;放;}publicdoubleSomeProperty2{get;放;}publicstringSomeProperty3{get;放;用这个属性装饰的类如下:[ExportMyInterface(typeof(string),0.1,"whoodata!")][ExportMyInterface(typeof(int),0.4,"asdfasdf!!")]publicclassDecoratedClass:IMyInterface{}尝试像这样使用导入的方法:privatevoidSomeFunction(){//CompositionContainer是CompositionCont的一个实例ainervarmyExports=CompositionContainer.GetExports();在我的例子中,myExports总是空的在我的CompositionContainer中,我的目录中有一个部分,它有两个ExportDefinitions,它们都具有以下ContractName:“MyNamespace.IMyInterface”。我的导出也正确加载元数据。如果我删除AllowMultiplesetter并仅包含一个导出属性,则myExports变量现在具有单个导出及其加载的元数据。我究竟做错了什么?编辑:如果我使用弱类型元数据,我的出口突然满足:varmyExports=CompositionContainer.GetExports
