WCF Client proxy
If we are creating a WCF application and we are not using sessions and unmanaged resources then it is necessary to close WCF client proxy. If yes then why its so?
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.


Amit ChoudharyRank #145 · 15.8K reputationPosted Aug 24, 2011, 8:47 PM EDT
{
///
/// Transitions proxy to closed state via Close() or Abort()
/// dependently on current proxy state
///
public static void CloseProxy
{
try
{
if (proxy.State != CommunicationState.Closed &&
proxy.State != CommunicationState.Faulted)
{
proxy.Close(); // may throw exception while closing
}
else
{
proxy.Abort();
}
}
catch (CommunicationException)
{
proxy.Abort();
throw;
}
}
}