WCF 4 close client proxy

In the old days (.net framework 3.5) we need to be careful to close the WCF client proxies.

In WCF 4 the Close is not available from the client. But it is available inside the proxy.

public class ServiceProxy : System.ServiceModel.ClientBase<IService>, ILoginService
{
}

Is closing the client proxy no longer required? Or how do we do it?

Answers


WCF Proxy need to be closed explicitly and if you are using the using() statement, you have the possibility of loosing the original exception. You can find details about this issue in the following posts.

From: http://geekswithblogs.net/SudheersBlog/archive/2009/09/01/134430.aspx

http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/b95b91c7-d498-446c-b38f-ef132989c154 http://geekswithblogs.net/marcel/archive/2007/05/01/112159.aspx

It is a recommended best practice to always close the proxy when the client is done using it, because closing the proxy terminates the session with the service and closes the connection.

Alternatively, you can use the Dispose() method of the proxy to close it. The advantage of the Dispose() method is that you can use the using statement to call it even in the face of exceptions

check

http://geekswithblogs.net/SoftwareDoneRight/archive/2008/05/23/clean-up-wcf-clients--the-right-way.aspx

http://geekswithblogs.net/bcaraway/archive/2008/07/06/123622.aspx


Need Your Help

Hadoop performance analysis (Wordcount vs Grep)

algorithm hadoop grep word-count

I am working on Hadoop performance analysis and I am running some benchmarks on Hadoop. What's surprising is that Grep takes almost 1/10 of the time it takes wordcount to run which is very non-intu...

How to make REST POST calls in R

r

I have been using jsonlite to make REST GET calls. The number of parameters have increased and I am wondering how to make a REST POST call using R.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.