Error with EventAggregator and events with identical names

Topics: Prism v1, Prism v2 - WPF 3.5
Jul 22, 2009 at 3:39 AM

I came across this issue in the last couple of days and though it might be of interest to people.

I have 2 presenters, and each which to subscribe to a global event fired by an Event Aggreator.

In each presenter I have the following line of code


where PerformMyResponse is a method with the appropriate signature.

What I find is that only the registation from the 2nd presenter is ever fired. The reason for this is that the event signatures are the same. I.e. they are both called "PerformMyEventResponse". The issue is easily resolved by giving the 2 methods distinct names, although it makes me wonder what is going on in the background of EventAggregator that stops it from executing the first delegate.

Anyone from the PRISM team care to comment on this?




Jul 22, 2009 at 6:47 PM

Hi Justin,

I have tried to reproduce your issue with no success. You can check the InternalSuscribe method in the EventBase class, and after both subscriptions have been performed check the Subscription count.
To reproduce your scenario, in the EventAggregator Quickstart I tried subscribing to the FundAddedEvent in the Presenter of each module using the code below and all handlers were fired:


A possible reason for events not firing could be because the event is being implemented with Weak References (this post provides a detailed scenario about it). However, this probably is not your scenario because when you call the methods differently your handlers get fired.

Could you provide a small repro sample?

Please let me know if this helps.

Damian Schenkelman

Jul 23, 2009 at 4:06 AM

Hi Damian,

Thanks for the quick response. You were actually spot on with your diagnosis. It was to do with weak referencing. The reason my original post thought it was a naming thing was that due to the indetermiante nautre of the garbages collector, the reference was not collected in the 2 runs after I changed the name, but was in the previous runs. How's that for a quirky coincidence?

Problem is now solved. Thanks so much for your help.