传输方式为nettcpbinding 绑定方式,下面这段代码会报错误,错误信息如下:
ChannelFactory 不支持协定 ITaskManage,因为它使用一个或多个操作定义回调协定。请考虑使用 DuplexChannelFactory 而不是 ChannelFactory。
1 //nettcpbinding 绑定方式 2 public static object ExecuteMethod<T>(string pUrl, string pMethodName,params object[] pParams) 3 { 4 EndpointAddress address = new EndpointAddress(pUrl); 5 Binding bindinginstance = null; 6 BasicHttpBinding ws = new BasicHttpBinding(); 7 ws.MaxReceivedMessageSize = 20971520; 8 bindinginstance = ws; 9 using (ChannelFactory<T> channel = new ChannelFactory<T>(bindinginstance, address)) 10 { 11 T instance = channel.CreateChannel(); 12 using (instance as IDisposable) 13 { 14 try 15 { 16 Type type = typeof(T); 17 MethodInfo mi = type.GetMethod(pMethodName); 18 return mi.Invoke(instance, pParams); 19 } 20 catch (TimeoutException) 21 { 22 (instance as ICommunicationObject).Abort(); 23 throw; 24 } 25 catch (CommunicationException) 26 { 27 (instance as ICommunicationObject).Abort(); 28 throw; 29 } 30 catch (Exception vErr) 31 { 32 (instance as ICommunicationObject).Abort(); 33 throw; 34 } 35 } 36 } 37 }
哪位大神有完整的动态调用.svc程序源码(WCF双工模式下)!!!
nettcpbinding你new一个BasicHttpBinding来绑定貌似有点问题吧,把binging换成NetTcpBinding试试~