EventAggregator on 1.3

Jan 23, 2012 at 4:55 PM

Hello folks,

am I the only one experiencing problem with EventAggregator and subscribe of IHandle<someMessage>()?

With 1.2 it was working, I am sure... now with 1.3  I have the message published as

   74   ReportMessage message = new ReportMessage();


   76             myUser user = _repository.GetLoggedUser();


   78             message.ReportHeader = clickedItem.Description;

   79             message.ReportType = ReportTypeEnum.Type0;


   81             message.Parameters.Add("...", ...);

   82             message.Parameters.Add("data", Date);




and in the listener 


 [Export]    public class ReportContainerViewModel : Conductor<IScreen>.Collection.AllActive, IHandle<ReportMessage>, IHaveDockPreferences, IHaveDockPinStatus




   void IHandle<ReportMessage>.Handle(ReportMessage message)        {            IReportViewModel reportViewModel = _viewModelFactory.Get<ReportViewModel>();
            reportViewModel.Parameters = message.Parameters;            reportViewModel.ReportType = message.ReportType;            reportViewModel.DisplayName = message.ReportHeader;
            ActivateItem(reportViewModel);        }


never get here...



Jan 23, 2012 at 5:07 PM

One other thing I changed is the fact that now the pusblisher resides in a DLL outside the subscriber... can this be the problem?


Jan 23, 2012 at 7:21 PM

You didn't state what your actual problem was. Also, can you post using the code formatting...it's hard to read the code as it is.

Jan 23, 2012 at 7:28 PM


you're right...  I have a reportviewmodel container, that handle IHandle<ReportMessage>, before splitting into modules and upgrading to 1.3 I have an event catched by the ReportContainerViewModel, now it won't stop when a message is published...

In my application I've also other event published/subscribed and they work (as for notification purpose/menuitem click) and they reside in the same assembly...

The problem I got is related to the fact I try to message between two modules?


Jan 24, 2012 at 9:03 AM


here it's the code that should subscribe to event



 public class ReportContainerViewModel : Conductor<IScreen>.Collection.OneActive, IHandle<ReportMessage>, IHaveDockPreferences, IHaveDockPinStatus


     private readonly IEventAggregator _eventAggregator;

     private readonly IApplicationRepository _applicationRepository;

     private readonly IViewModelFactory _viewModelFactory;




     public ReportContainerViewModel(IEventAggregator eventAggregator, IApplicationRepository applicationRepository, IViewModelFactory viewModelFactory)



         _eventAggregator = eventAggregator;

         _applicationRepository = applicationRepository;

         _viewModelFactory = viewModelFactory;


         DisplayName = "Report Container";






     public void Close(IReportViewModel report)


         bool close = true;

         DeactivateItem(report, close);




     protected override void OnViewLoaded(object view)







     public DelegateCommand RemoveItemCommand { get; set; }


     #region IHaveDockPreferences Members


     public DockingStateEnum InitialState


         get { return DockingStateEnum.DockedRight; }





     public bool IsPinned


         get { return false; }



     #region IHandle<ReportMessage> Members


     void IHandle<ReportMessage>.Handle(ReportMessage message)


         IReportViewModel reportViewModel = _viewModelFactory.Get<ReportViewModel>();


         reportViewModel.Parameters = message.Parameters;

         reportViewModel.ReportType = message.ReportType;

         reportViewModel.DisplayName = message.ReportHeader;








The message is sent in a viewmodel defined in another assembly

and the code is :


public void BtnClicked(MyResult clickedItem)


         if (clickedItem == null) throw new ArgumentNullException("clickedItem");


         ReportMessage message = new ReportMessage();


         myUser user = _repository.GetLoggedUser();


         message.ReportHeader = clickedItem.INTESTAZIONE;

         message.ReportType = ReportTypeEnum.Type0;


         message.Parameters.Add("id", clickedItem.ID);

         message.Parameters.Add("data", Date);

         message.Parameters.Add("iduser", user.IDUser);





The problem is that the event is that it never pass in void IHandle<ReportMessage>.Handle(ReportMessage message) {}



Jan 24, 2012 at 5:16 PM


found the problem..... I left a ReportMessage.cs inside a Messages folder so I have 2 different ReportMessage class and the eventpublisher doesn't (correctly) know how to handle....thanks, sorry for the confusion

Jan 24, 2012 at 9:32 PM

No problem. I'm glad you figured it out...because I was stumped ;)