Question

I have a service object which has method having callback implementation mentioned below

public string GetMacName()
{
string value = System.Environment.MachineName.ToString();
msgCallback = OperationContext.Current.GetCallbackChannel<IServiceCallBack>();
 msgCallback.Notify(value);
return value;
}

I have created a DuplexChannelfactory and got the service object in my client. Now, with the service object I retrieve Type as Client Side:

DuplexChannelFactory<IServiceOne> factory = new DuplexChannelFactory<IServiceOne>(callbackInstance, new NetTcpBinding(), "uri");
proxyObject = factory.CreateChannel(); Type t=  proxyObject.GetType();

I have implemented IServiceOneCallback method in client

public string Notify(string value)
{
Notification=value;
} 

I am invoking the method GetMacName() as mentioned below:

t.Invoke("GetMacName", BindingFlags.Default | BindingFlags.InvokeMethod, null, proxyObject, args); 

this is getting failed... where i m wrong,is something for callback needs to done in Invoke

Était-ce utile?

La solution

Got it working... [CallbackBehavior(ConcurrencyMode=ConcurrencyMode.Multiple,UseSynchronizationCon‌​text=false)] attribute needs to be added for wpf or winform application, something to do with synchronization context. Thank you for your inputs.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top