tags:

views:

40

answers:

1

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();

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

A: 

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

Bronumski