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?
PubSubEvent<T>
located in the same assembly withMyAggregatorEvent
? If not, you need to add reference to this assembly from project where you wrotePublishEvent()
. – FkaPubSubEvent 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