Reputation: 674
I am trying to pass an Prism IEventAggregator object via WCF service. However, object returned by WCF service seems to be a different object or modified. As, while debugging, I can see IEventAggregator object have n numbers of events in operation contract method Implementation. However, when test access it , it has zero event.
Here's my code:
Process A (Product)
[ServiceContract(SessionMode = SessionMode.Allowed, ProtectionLevel = ProtectionLevel.None)]
public interface ITest
{
[OperationContract]
[ServiceKnownType(typeof(IEventAggregator))]
[ServiceKnownType(typeof(MefEventAggregator))]
IEventAggregator GetEventAggregator();
}
public class TestImpl : ITest
{
public IEventAggregator GetEventAggregator()
{
// Assume an instance of IEventAggregator is added in repo.
return Repo.GetServiceOfType<IEventAggregator>();
**// in debug mode - it has n events**
}
}
Process B (Test): (which has all required configuration to access this wcf service
TestA
{
var proxyClient =CreateProxyObject();
var eventAgg = proxyClient.GetEventAggregator();
**// eventAgg has zero events**
}
Upvotes: 1
Views: 51
Reputation: 10883
The event aggregator works by storing its subscriptions in a static field and it has no idea about being passed through a wcf channel. It will work fine locally, but it won't magically acquire inter-process capabilities.
What you can do (besides using some inter-process message passing framework), is to publish the events on the server and create methods on the server's interface to publish the events from the clients. This should, theoretically, work for client-side subscriptions, too, given you have a two-way-contract. I expect a ton of boilerplate code, though...
Upvotes: 1