I have the following code for recreating a WCf client in a non opened state
if (client.State != CommunicationState.Opened)
{
client.Abort();
client = null;
Trace.WriteLine("Client object in non opened state. Recreating object");
client = new <WCFClient>("NetTcpBindingEndpoint", ConfigurationManager.AppSettings["ServiceEndPointAddress"]);
client.Open();
}
For some reason though, as soon as this routine returns and I try to call client.Somemethod(), I get an exception and when I catch it, I see the client in a faulted state. I don’t understand how this happened so quickly.
Thanks for any help in advance.
Subbu
Can you show us when you’re trying to call
client.SomeMethod()?I don’t see what you’re trying to achieve with the
client.Open()here….. that really doesn’t make any sense at all – just call the method you want to call!and maybe add some
try.....catchmagic around it to make it safer…. but that’s really all you need – no need to first.Open()the client…..