Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does the C# WCF Proxy ClientBase<T> Disposal issue still exist in .Net 4.5+

In earlier versions of C#.Net an issue exists when disposing of WCF Proxies (Service Reference generated clients) - Does this still exist in .Net 4.5+?

Full details of this issue can be found here... https://coding.abel.nu/2012/02/using-and-disposing-of-wcf-clients ...but to summarize, essentially the IDisposable implementation on the Service Reference generated proxy, unconditionally called Close() without first checking the State. If an unhandled exception was ever thrown from the service being called, this would fault the channel, and then doing ANYTHING with the proxy (including trying to call Dispose()) would give rise to a secondary CommunicationException - obfuscating the original exception, and leaving the Proxy in an un-usable state. With this in mind, one couldn't really wrap the proxy in the using{} construct despite the fact that it implemented IDisposable, and it was largely regarded as a WCF bug.

Several patterns exist for dealing with this, and I'm not going to cover them here. What I need to know is, as it was largely regarded as a WCF bug, has it been fixed? I can't find anything on the interweb to suggest that the flawed implementation of IDisposable is no longer flawed??

UPDATE: I've just found this... https://msdn.microsoft.com/en-us/library/aa355056(v=vs.110).aspx ...which suggests it's still an issue. Can't believe it hasn't been fixed yet. This issue has been around since WCF first appeared. What's the point of implementing IDisposable on these proxies??

like image 425
controlbox Avatar asked Sep 23 '22 02:09

controlbox


1 Answers

UPDATE: I've just found this... https://msdn.microsoft.com/en-us/library/aa355056(v=vs.110).aspx ...which suggests it's still an issue.

like image 61
controlbox Avatar answered Oct 18 '22 19:10

controlbox