0
votes

Currently im trying to implement an EventAggregator using prism to publish and subscribe events in between two modules.

I try to implement it in the way described here MSDN. But i stuck already at the begin.

I implemented an event in my Infrastructure namespace:

namespace Infrastructure
{
    public class MyAggregatorEvent : PubSubEvent<string>{}
}

In my first module i would like to publish/raise this event in the following way"

private PublishEvent()
{
    IEventAggregator _eventAggregator = ServiceLocator.Current.GetInstance<IEventAggregator>();
    _eventAggregator.GetEvent<MyAggregatorEvent>().Publish("Test");
}

But the problem is that i cant call the Publish() method. I always get an error saying:

Infrastructure.MyAggregatorEvent' does not contain a definition for 'Publish' and no extension method 'Publish' accepting a first argument of type 'Infrastructure.MyAggregatorEvent' could be found (are you missing a using directive or an assembly reference?) D:\PviVm.cs ModulePvi

I read a lot of articles in the web but couldn't figure out what im doing wrong.

Has anybody an idea what im doing wrong?

1
Is PubSubEvent<T> located in the same assembly with MyAggregatorEvent? If not, you need to add reference to this assembly from project where you wrote PublishEvent().Fka
From the MSDN article you used: PubSubEvent can be found in the Microsoft.Practices.SubSubEvents namespace which is located in the Prism.PubSubEvents NuGet package. Did you include this assembly?Moti Azu

1 Answers

0
votes

Finally i found the problem.

I mixed up the class references in my modules.

I used PubSubEvent Class in one module and CompositePresentationEvent Class in the other module. This was the root cause for my initial problem.

After using PubSubEvent in all my modules it works.