开发者

The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state

try
{
    String endPointAddr = "net.tcp://localhost:8000/MyService";
    NetTcpBinding tcpBinding = new NetTcpBinding();
    tcpBinding.TransactionFlow = false;
    tcpBinding.Security.Transport.ProtectionLevel = System.Net.Security.ProtectionLevel.EncryptAndSign开发者_StackOverflow社区;
    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();

this code run fluently if dictionary has 50 to 100 records but records is greater than that error has been occurred The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state


Without seeing the stack trace or the code that is failing but it sounds like your wcf client has failed for some reason which has put it into a faulted state and you are trying to use it again. Or that you are using a using statement with your proxy.

Avoiding Problems with the Using Statement

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜