在调用后出错,winform回发给asp.net程序时出的错,报错连接断开没有这样的连接。开始asp.net连接后还可以调用winform服务端的方法,但是连接上后winform有个线程就会一直给asp.net的客户端发消息,在发消息的时候出错说没有连接,郁闷死。
部分asp.net 代码:
LoginUser = tbUserName.Text.Trim();
string password = tbPass.Text;
ServerUrl = string.Format("net.tcp://{0}:4502/CynosuraService", tbAddress.Text.Trim()); //(cbServers.SelectedItem as ComboBoxItem).Tag + ""; //"net.tcp://172.18.3.5:4502/CynosuraService";
EndpointAddress ea = new EndpointAddress(ServerUrl);
ICynosuraServiceCallback callback = new PromaxyCallBack();
InstanceContext context = new InstanceContext(callback);
BindingElementCollection elements = new BindingElementCollection();
elements.Add(new BinaryMessageEncodingBindingElement());
elements.Add(new TcpTransportBindingElement { MaxReceivedMessageSize = 2147483647, MaxBufferSize = 2147483647 });
CustomBinding binding = new CustomBinding(elements);
ServiceReference1.CynosuraServiceClient client = new ServiceReference1.CynosuraServiceClient(context, binding, ea);
client.Open();
//这边可以调用到winform的Subscribe方法注册后,理论上winform中另外的线程会回调到asp.net类中的方法,PromaxyCallBack定义的asp.net中:Push方法,但是没有实现,应该也可以调用到吧?但是就是没掉用到,winform中调用push时报错没有连接什么的。why?
bool loginSuccess = client.Subscribe(LoginUser, password);
int i=0;
谢谢
PromaxyCallBack 定义:
/// <summary>
/// Summary description for PromaxyCallBack
/// </summary>
public class PromaxyCallBack : ICynosuraServiceCallback
{
public void ClearData(int zone)
{
//throw new NotImplementedException();
}
public void GetRecipeChartInfo(GetRecipeChartInfo request)
{
// throw new NotImplementedException();
}
public void Push(Push request)
{
//throw new NotImplementedException();
}
}