Silverlight 5.0应用prism的Mef容器总是报错的解决方案

本文详细介绍了在使用Silverlight5.0版本时遇到Prism版本Mef容器加载失败的问题,即'System.Reflection.ReflectionTypeLoadException'错误。主要原因是Silverlight版本与Prism容器版本不兼容。为了解决此问题,文章推荐将Silverlight客户端的版本更改为4.0。同时,文章还提到了在使用不同的容器时(如Unity容器),Silverlight版本与容器版本之间的兼容性差异。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

      如果本机安装的是Silverlight 5.0版本,而你要用prism版本的Mef容器,就会一直出错,出错的信息是:Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.

       查看详细的错误信息是:System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
   at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
   at System.Reflection.RuntimeModule.GetTypes()
   at System.Reflection.Assembly.GetTypes()
   at System.ComponentModel.Composition.Hosting.AssemblyCatalog.get_InnerCatalog()
   at System.ComponentModel.Composition.Hosting.AssemblyCatalog.get_Parts()
   at Microsoft.Practices.Prism.MefExtensions.DefaultPrismServiceRegistrar.GetRequiredPrismPartsToRegister(AggregateCatalog aggregateCatalog)
   at Microsoft.Practices.Prism.MefExtensions.DefaultPrismServiceRegistrar.RegisterRequiredPrismServicesIfMissing(AggregateCatalog aggregateCatalog)
   at Microsoft.Practices.Prism.MefExtensions.MefBootstrapper.RegisterDefaultTypesIfMissing()
   at Microsoft.Practices.Prism.MefExtensions.MefBootstrapper.Run(Boolean runWithDefaultConfiguration)
   at Microsoft.Practices.Prism.Bootstrapper.Run()
   at SilverlightPrism.App.Application_Startup(Object sender, StartupEventArgs e)
   at MS.Internal.CoreInvokeHandler.InvokeEventHandler(UInt32 typeIndex, Delegate handlerDelegate, Object sender, Object args)
   at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName, UInt32 flags)

要解决这个错误的办法是:把Silverlight客户端的Silverlight版本改为4.0就可以了,我不知道还有没有其它更好的解决方案,如果有请指教了。

但如果你是用Sliverlight 5.0版本,而用prism的Unity容器的话,是没有这个错误的。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值