帮我分析一下错误原因,以及如何处理

杨根祥 2010-11-29 05:31:20
用户代码未处理 Microsoft.Practices.Composite.Presentation.Regions.Behaviors.RegionCreationException
Message=An exception occurred while creating a region with name 'MenuRegion'. The exception was: Microsoft.Practices.Unity.ResolutionFailedException: Resolution of the dependency failed, type = "Silverlight.Modules.Main.Views.IMenuViewModel", name = "(none)".
Exception occurred while: Calling constructor Silverlight.Modules.Main.Views.MenuViewModel(Silverlight.Modules.Main.Views.IMenuView view, Microsoft.Practices.Unity.IUnityContainer container, Microsoft.Practices.Composite.Events.IEventAggregator eventAggregator).
Exception is: ResolutionFailedException - Resolution of the dependency failed, type = "Silverlight.Modules.Main.Controllers.IMainController", name = "(none)".
Exception occurred while: while resolving.
Exception is: InvalidOperationException - The current type, Silverlight.Modules.Main.Controllers.IMainController, is an interface and cannot be constructed. Are you missing a type mapping?
-----------------------------------------------
At the time of the exception, the container was:

Resolving Silverlight.Modules.Main.Controllers.IMainController,(none)

-----------------------------------------------
At the time of the exception, the container was:

Resolving Silverlight.Modules.Main.Views.MenuViewModel,(none) (mapped from Silverlight.Modules.Main.Views.IMenuViewModel, (none))
Calling constructor Silverlight.Modules.Main.Views.MenuViewModel(Silverlight.Modules.Main.Views.IMenuView view, Microsoft.Practices.Unity.IUnityContainer container, Microsoft.Practices.Composite.Events.IEventAggregator eventAggregator)
---> Microsoft.Practices.Unity.ResolutionFailedException: Resolution of the dependency failed, type = "Silverlight.Modules.Main.Controllers.IMainController", name = "(none)".
Exception occurred while: while resolving.
Exception is: InvalidOperationException - The current type, Silverlight.Modules.Main.Controllers.IMainController, is an interface and cannot be constructed. Are you missing a type mapping?
-----------------------------------------------
At the time of the exception, the container was:

Resolving Silverlight.Modules.Main.Controllers.IMainController,(none)
---> System.InvalidOperationException: The current type, Silverlight.Modules.Main.Controllers.IMainController, is an interface and cannot be constructed. Are you missing a type mapping?
位于 Microsoft.Practices.ObjectBuilder2.DynamicMethodConstructorStrategy.ThrowForAttemptingToConstructInterface(IBuilderContext context)
位于 BuildUp_Silverlight.Modules.Main.Controllers.IMainController(IBuilderContext )
位于 Microsoft.Practices.ObjectBuilder2.DynamicMethodBuildPlan.BuildUp(IBuilderContext context)
位于 Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp(IBuilderContext context)
位于 Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)
位于 Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object existing, String name, IEnumerable`1 resolverOverrides)
--- 内部异常堆栈跟踪的结尾 ---
位于 Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object existing, String name, IEnumerable`1 resolverOverrides)
位于 Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, String name, IEnumerable`1 resolverOverrides)
位于 Microsoft.Practices.Unity.UnityContainer.Resolve(Type t, String name, ResolverOverride[] resolverOverrides)
位于 Microsoft.Practices.Unity.UnityContainerExtensions.Resolve[T](IUnityContainer container, ResolverOverride[] overrides)
位于 Silverlight.Modules.Main.Views.MenuViewModel.InitializeButtons()
位于 Silverlight.Modules.Main.Views.MenuViewModel..ctor(IMenuView view, IUnityContainer container, IEventAggregator eventAggregator)
位于 BuildUp_Silverlight.Modules.Main.Views.MenuViewModel(IBuilderContext )
位于 Microsoft.Practices.ObjectBuilder2.DynamicMethodBuildPlan.BuildUp(IBuilderContext context)
位于 Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp(IBuilderContext context)
位于 Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)
位于 Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object existing, String name, IEnumerable`1 resolverOverrides)
--- 内部异常堆栈跟踪的结尾 ---
位于 Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object existing, String name, IEnumerable`1 resolverOverrides)
位于 Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, String name, IEnumerable`1 resolverOverrides)
位于 Microsoft.Practices.Unity.UnityContainer.Resolve(Type t, String name, ResolverOverride[] resolverOverrides)
位于 Microsoft.Practices.Unity.UnityContainerExtensions.Resolve[T](IUnityContainer container, ResolverOverride[] overrides)
位于 Silverlight.Modules.Main.MainModule.<Initialize>b__1()
位于 Microsoft.Practices.Composite.Presentation.Regions.RegionViewRegistry.GetContents(String regionName)
位于 Microsoft.Practices.Composite.Presentation.Regions.Behaviors.AutoPopulateRegionBehavior.CreateViewsToAutoPopulate()
位于 Microsoft.Practices.Composite.Presentation.Regions.Behaviors.AutoPopulateRegionBehavior.StartPopulatingContent()
位于 Microsoft.Practices.Composite.Presentation.Regions.Behaviors.AutoPopulateRegionBehavior.OnAttach()
位于 Microsoft.Practices.Composite.Presentation.Regions.RegionBehavior.Attach()
位于 Microsoft.Practices.Composite.Presentation.Regions.RegionBehaviorCollection.Add(String key, IRegionBehavior regionBehavior)
位于 Microsoft.Practices.Composite.Presentation.Regions.RegionAdapterBase`1.AttachDefaultBehaviors(IRegion region, T regionTarget)
位于 Microsoft.Practices.Composite.Presentation.Regions.RegionAdapterBase`1.Initialize(T regionTarget, String regionName)
位于 Microsoft.Practices.Composite.Presentation.Regions.RegionAdapterBase`1.Microsoft.Practices.Composite.Regions.IRegionAdapter.Initialize(Object regionTarget, String regionName)
位于 Microsoft.Practices.Composite.Presentation.Regions.Behaviors.DelayedRegionCreationBehavior.CreateRegion(DependencyObject targetElement, String regionName).
StackTrace:
位于 Microsoft.Practices.Composite.Presentation.Regions.Behaviors.DelayedRegionCreationBehavior.CreateRegion(DependencyObject targetElement, String regionName)
位于 Microsoft.Practices.Composite.Presentation.Regions.Behaviors.DelayedRegionCreationBehavior.TryCreateRegion()
位于 Microsoft.Practices.Composite.Presentation.Regions.Behaviors.DelayedRegionCreationBehavior.ElementLoaded(Object sender, RoutedEventArgs e)
位于 MS.Internal.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args)
位于 MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName)
InnerException: Microsoft.Practices.Unity.ResolutionFailedException
Message=Resolution of the dependency failed, type = "Silverlight.Modules.Main.Views.IMenuViewModel", name = "(none)".
Exception occurred while: Calling constructor Silverlight.Modules.Main.Views.MenuViewModel(Silverlight.Modules.Main.Views.IMenuView view, Microsoft.Practices.Unity.IUnityContainer container, Microsoft.Practices.Composite.Events.IEventAggregator eventAggregator).
Exception is: ResolutionFailedException - Resolution of the dependency failed, type = "Silverlight.Modules.Main.Controllers.IMainController", name = "(none)".
Exception occurred while: while resolving.
Exception is: InvalidOperationException - The current type, Silverlight.Modules.Main.Controllers.IMainController, is an interface and cannot be constructed. Are you missing a type mapping?
...全文
443 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
frank6027 2010-11-30
  • 打赏
  • 举报
回复
Calling constructor 这个异常吧,楼主看这个函数里的就行了应该是构造函数
杨根祥 2010-11-30
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 jv9 的回复:]
你使用了PRISM么?其中创建'MenuRegion'实例失败,应该这里引用为null了,检查一下错误行是否被提前实例成功。
[/Quote]
是的,我用了Prism,我再看一下程序。
passself 2010-11-30
  • 打赏
  • 举报
回复
Calling constructor 这个异常吧,楼主看这个函数里的就行了应该是构造函数
jv9 2010-11-30
  • 打赏
  • 举报
回复
你使用了PRISM么?其中创建'MenuRegion'实例失败,应该这里引用为null了,检查一下错误行是否被提前实例成功。
杨根祥 2010-11-30
  • 打赏
  • 举报
回复
谢谢大家。

8,737

社区成员

发帖
与我相关
我的任务
社区描述
WPF/Silverlight相关讨论
社区管理员
  • WPF/Silverlight社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧