首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >试图获取IXXXXXController类型“键”的实例时发生激活错误

试图获取IXXXXXController类型“键”的实例时发生激活错误
EN

Stack Overflow用户
提问于 2018-01-16 11:49:38
回答 1查看 370关注 0票数 0

当尝试使用ServiceLocator.Current.GetInstance()方法获取对象时,我们会遇到以下错误。

激活错误发生在试图获取IXXXXXController类型的实例时,键“

在Microsoft.Internal.Collections.WeakReferenceCollection1.<CleanupDeadReferences>b__0(WeakReference w) at System.Collections.Generic.List1.RemoveAll(Predicate1 match) at Microsoft.Internal.Collections.WeakReferenceCollection1.CleanupDeadReferences() at Microsoft.Internal.Collections.WeakReferenceCollection`1.Add(T item) at System.ComponentModel.Composition.Hosting.ImportEngine.StartSatisfyingImports(PartManager partManager,AtomicComposition atomicComposition) at System.ComponentModel.Composition.Hosting.ImportEngine.TrySatisfyImports(PartManager partManager,ComposablePart part,System.ComponentModel.Composition.Hosting.ImportEngine.SatisfyImports(ComposablePart shouldTrackImports)在System.ComponentModel.Composition.Hosting.CompositionServices.GetExportedValueFromComposedPart(ImportEngine engine,ComposablePart part,

( System.ComponentModel.Composition.Hosting.CatalogExportProvider.GetExportedValue(CatalogPart部件的ExportDefinition定义),System.ComponentModel.Composition.Primitives.Export.get_Value()的ExportDefinition导出( System.ComponentModel.Composition.ReflectionModel.ImportingItem.Cast(Type类型),System.ComponentModel.Composition.ReflectionModel.ImportingItem.CastSingleExportToImportType(Type类型的导出(System.ComponentModel.Composition.ReflectionModel.ImportingItem.CastSingleExportToImportType(Type)),(出口)在System.ComponentModel.Composition.ReflectionModel.ImportingItem.CastExportsToSingleImportType(Export[]出口)在System.ComponentModel.Composition.ReflectionModel.ImportingItem.CastExportsToImportType(Export[]出口)在System.ComponentModel.Composition.ReflectionModel.ReflectionComposablePart.SetImport(ImportingItem项目下,Export[]出口)在System.ComponentModel.Composition.ReflectionModel.ReflectionComposablePart.SetImport(ImportDefinition定义,IEnumerable1 exports) at System.ComponentModel.Composition.Hosting.ImportEngine.PartManager.TrySetImport(ImportDefinition import, Export[] exports) at System.ComponentModel.Composition.Hosting.ImportEngine.TrySatisfyImportSubset(PartManager partManager, IEnumerable1进口,AtomicComposition

(在System.ComponentModel.Composition.Hosting.ImportEngine.TrySatisfyImportsStateMachine(PartManager partManager,ComposablePart部件)在System.ComponentModel.Composition.Hosting.ImportEngine.TrySatisfyImports(PartManager partManager,ComposablePart部件,布尔shouldTrackImports(在System.ComponentModel.Composition.Hosting.ImportEngine.SatisfyImports(ComposablePart部件)在System.ComponentModel.Composition.Hosting.CompositionServices.GetExportedValueFromComposedPart(ImportEngine引擎,ComposablePart部件,

( System.ComponentModel.Composition.Hosting.CatalogExportProvider.GetExportedValue(CatalogPart part,ExportDefinition导出,布尔型isSharedPart)在System.ComponentModel.Composition.Primitives.Export.get_Value() at System.ComponentModel.Composition.Primitives.Export.get_Value() at System.ComponentModel.Composition.ExportServices.GetCastedExportedValueT at System.ComponentModel.Composition.ExportServices.<>c__DisplayClass102.<CreateSemiStronglyTypedLazy>b__c() at System.Lazy1.CreateValue() at System.Lazy1.LazyInitValue() at System.Lazy1.get_Value() at Microsoft.Practices.Prism.MefExtensions.MefServiceLocatorAdapter.DoGetInstance(Type serviceType,( c:\release\WorkingDir中的字符串键)

\PrismLibraryBuild\PrismLibrary\Desktop\Prism.MefExtensions\MefServiceLocatorAdapter.cs:line 73 at Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance(Type serviceType,字符串键)

我们正在设置类中的容器(内部覆盖无效ConfigureAggregateCatalog方法),该容器来自MefBootstrapper,如下所示

this.AggregateCatalog.Catalogs.Add(new AssemblyCatalog(typeof(ClassName).Assembly));

我们已经观察到这个工作很好已经有一段时间了,但是当我们离开应用程序理想的几个小时时,我们开始得到错误。请提出导致此错误的原因,并对其进行修复。

谢谢

EN

回答 1

Stack Overflow用户

发布于 2018-01-16 14:55:16

不要用MEF和棱镜。MEF的支持将在未来的版本中被放弃。请用真正的容器。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48280588

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档