我在我的代码中使用WCF服务,客户端(WindowsFormsApplication1)捕获桌面视图并将其发送到服务器。之后服务器将图像发送到Masterclient(windowsformsApplication2)。其工作...但几分钟,我得到了来自客户方的例外,因为对象引用不是设置对象我怎样才能解决这个问题的一个实例....WCF客户端中的异常
,这是mycode的:
public void SendToServerToMainServer(clsImageObject img)
{
ConnectToServerSettings();
InterfaceClass.IService serviceobj = Client.CreateChannel();// I got exception in This line,And the serviceobj got null Suddenly...
serviceobj.SendToServerToMasterClient(img, clpro.MyIPAddress);
Client.Close();
Client = null;
}
}
public void ConnectToServerSettings()
{
string StrAddress = File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "url1.txt");
//EndpointAddress ea = new EndpointAddress(@"net.tcp://10.0.3.33:2222/ClsPCMain");
EndpointAddress ea = new EndpointAddress(StrAddress);
NetTcpBinding binding = new NetTcpBinding(SecurityMode.None, false);
//binding.TransferMode = TransferMode.Streamed;
binding.MaxBufferPoolSize = Int32.MaxValue;
binding.MaxReceivedMessageSize = Int32.MaxValue;
binding.PortSharingEnabled = true;
binding.ReceiveTimeout = TimeSpan.MaxValue;
binding.SendTimeout = TimeSpan.MaxValue;
binding.OpenTimeout = TimeSpan.MaxValue;
binding.CloseTimeout = TimeSpan.MaxValue;
binding.MaxReceivedMessageSize = Int32.MaxValue;
binding.MaxBufferPoolSize = Int32.MaxValue;
binding.MaxConnections = Int16.MaxValue;
binding.ReaderQuotas.MaxArrayLength = Int32.MaxValue;
binding.ReaderQuotas.MaxBytesPerRead = Int32.MaxValue;
binding.ReaderQuotas.MaxDepth = Int32.MaxValue;
binding.ReaderQuotas.MaxNameTableCharCount = Int32.MaxValue;
binding.ReaderQuotas.MaxStringContentLength = Int32.MaxValue;
binding.Security.Mode = SecurityMode.None;
Client = new ChannelFactory<InterfaceClass.IService>(binding, ea);
}
}
你能否提供一些关于异常的地方的信息(即什么实际上是空的)? – 2010-02-13 13:09:09
我已经在注释行中的代码中给出了它...它是在第一个函数SendToServerToMainServer(clsImageObject img)... – Suryakavitha 2010-02-13 14:04:10
serviceobj对象获取null .. – Suryakavitha 2010-02-15 05:42:22