Click here to Skip to main content
13,248,295 members (36,386 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


4 bookmarked
Posted 18 May 2011

Do not use "using" for WCF Clients

, 18 May 2011
Good Tip, got my 5!As an alternative to your tip, when using generated proxies you could also add the logic to a partial class with the same name as the proxy class, see below.public partial class MyGeneratedProxyClient : IDisposable{ void IDisposable Dispose() { try...


Members may post updates or alternatives to this current article in order to show different approaches or add new features.

22 May 2011
Jeremy Hutchinson
Or you can use T4 to generate a static class wrapper around the service. Then your call can look like this:SvcWrapper.Login(username, password);The full explanation and sample code is located here[^].
17 May 2011
Omar Al Zabir
2 alternatives  
Traditional using() block disposes WCF clients incorrectly when there's a communication exception, eg dropping network connection. It raises exception during the dispose and thus the resources held by the WCF client aren't released properly. After some time, you end up with memory leaks.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Patrick Kalkman
Netherlands Netherlands
Patrick Kalkman is a senior Software Architect with more than 20 years professional development experience. He works for SimpleTechture where he helps teams develop state of the art web applications.

Patrick enjoys writing his blog. It discusses agile software development. Patrick can be reached at

Published Windows 8 apps:

Published Windows Phone apps:


Best Mobile article of March 2012
Best Mobile article of June 2012

| | Privacy | Terms of Use | Mobile
Web03 | 2.8.171114.1 | Last Updated 18 May 2011
Article Copyright 2011 by Patrick Kalkman
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid