Failiing to inject event aggregator

Topics: Prism v2 - Silverlight 4
Nov 29, 2010 at 11:07 AM


i'm using PRISM for my SL project. Everything was okay until today i started getting the following error

Resolution of the dependency failed, type = "PwC.SMART.UI.Silverlight.Modules.Navigation.ImportAndExport.ImportExportSearchFacilityView", name = "(none)".
Exception occurred while: while resolving.
Exception is: InvalidOperationException - The current type, Microsoft.Practices.Composite.Events.IEventAggregator, is an interface and cannot be constructed. Are you missing a type mapping?
At the time of the exception, the container was:

  Resolving PwC.SMART.UI.Silverlight.Modules.Navigation.ImportAndExport.ImportExportSearchFacilityView,(none)
  Resolving parameter "eventAggregator" of constructor PwC.SMART.UI.Silverlight.Modules.Navigation.ImportAndExport.ImportExportSearchFacilityView(Microsoft.Practices.Composite.Events.IEventAggregator eventAggregator)
    Resolving Microsoft.Practices.Composite.Events.IEventAggregator,(none)

I have views(both usercontrols and child windows) in this module and other modules which are working perfectly. I'm getting error for this particular view.



Nov 29, 2010 at 4:48 PM

Hi Saheer,

Based on my understanding, your issue is caused because the IEventAggregator type mapping isn't in place when you try to resolve it. In order for the Unity Container to resolve an IEventAggregator, a type mapping to a concrete type (the EventAggregator concrete class, in this case) is needed, since an interface by itself cannot be constructed.

The mapping might not be there because:

  • You're trying to resolve the IEventAggregator before the UnityBootstrapper has registered the type mapping, or
  • you're not using the same instance fo the Unity Container that has been used to register the type mapping.

If you continue experiencing the same situation, it would be useful if you could provide more information about your view, and when and how it is created.

I hope you find this helpful,

Guido Leandro Maliandi