我在我的代碼中使用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