try
{
String endPointAddr = "net.tcp://localhost:8000/MyService";
NetTcpBinding tcpBinding = new NetTcpBinding();
tcpBinding.TransactionFlow = false;
tcpBinding.Security.Transport.ProtectionLevel = System.Net.Security.ProtectionLevel.EncryptAndSign;
tcpBinding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Windows;
tcpBinding.Security.Mode = SecurityMode.None;
EndpointAddress endpointAddress = new EndpointAddress(endPointAddr);
Console.WriteLine("::::: WCF Service Demo :::::");
Console.WriteLine("Attempt to connect to: " + endPointAddr);
ChannelFactory<IServices> WCF = new ChannelFactory<IServices>(tcpBinding, endpointAddress);
IServices proxy = WCF.CreateChannel();
using (WCF as IDisposable)
{
Console.WriteLine("Connected to: " + endPointAddr);
Dictionary<long, DATALINK> dicDataLink = proxy.getDataLink();
lblCTRGData.Text = dicTRGDataLink.Count.ToString();
}
}
catch (Exception ex)
{
lblCTRGData.Text = ex.Message.ToString();
}
Console.ReadLine();
如果字典有50到100條記錄但記錄大於該錯誤,則此代碼可以流暢地運行發生通信對象System.ServiceModel.Channels.ServiceChannel不能用於通信,因爲它處於Faulted狀態通信對象System.ServiceModel.Channels.ServiceChannel不能用於通信,因爲它處於Faulted狀態
而你的問題是?您是否有機會在使用語句中使用代理編寫服務調用,並且該服務發生錯誤? – Paddy 2010-07-28 09:27:02