1

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

Amiram Korach
  • 13,056
  • 3
  • 28
  • 30
Shabana
  • 69
  • 6
  • Why can't you call proxyObject.GetMacName()? – Amiram Korach Nov 19 '12 at 08:26
  • Add the exception stack trace to your question. – Karel Frajták Nov 19 '12 at 08:29
  • actually that is the requirement, i need to pass the method name and invoke from the object dynamically, strangely i have created a created a separate project and there it is working.... same code... Thanks for the input, need to check where is the problem. :( – Shabana Nov 19 '12 at 09:29
  • 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. – Shabana Nov 19 '12 at 10:20

1 Answers1

0

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.

Shabana
  • 69
  • 6