Fix the broken Dispose pattern on CommunicationObject-derived types.
using(var channel = cf.CreateChannel())
{
channel.ForTheLoveOf(wcf);
}
3 comments
-
Jonathan Schellack
commented
The first problem is that every .NET developer thinks that the using(var x = new X()){...} means that x is cleaned up properly and you don't have to worry about it again. So every .NET developer follows that same old pattern at first and ends up gnashing their teeth, because the same old pattern really doesn't follow the Dispose pattern.
The second problem is that you end up writing this code (http://bloggingabout.net/blogs/erwyn/archive/2006/12/09/WCF-Service-Proxy-Helper.aspx) over (http://blogs.microsoft.co.il/blogs/rotemb/archive/2008/07/30/WCF-Best-Practices_3A00_-How-to-Dispose-WCF-clients.aspx) and over (http://blogs.microsoft.co.il/blogs/rotemb/archive/2008/07/01/wcf-practices-writing-single-function-for-your-entire-wcf-proxy-calls.aspx) again, after you figure out that the `using` code that you can write shouldn't ever be written (http://social.msdn.microsoft.com/forums/en-US/wcf/thread/4cdc67e0-3069-4d3b-b94f-27e2b8ff4429/).
-
spenceee
commented
This is not a "known" issue. This is because the dispose pattern does not fit the WCF pattern well because of the behaviour of the service. The operations of "Close" vs. "Abort" are quite distinct and have very different effects on the client and server code. Which code should the dispose call? Should it try to do the error checking. If Close() throws, should it handle it, or let you know that your end user (potentially) didn't get a message.
-
Ben Cline
commented
It is sad when there are open issues for such a long time. Microsoft gets such a bad rep when there are known issues like this and says it is not a priority to fix bugs. Why not?