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 im wrong,is something for callback needs to done in Invoke
Got it working... [CallbackBehavior(ConcurrencyMode=ConcurrencyMode.Multiple,UseSynchronizationContext=false)] attribute needs to be added for wpf or winform application, something to do with synchronization context. Thank you for your inputs.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.