Shawn Weisfeld

I find when I talk to myself nobody listens. - Shawn Weisfeld
posts - 356, comments - 173, trackbacks - 34

My Links

News


Shawn Weisfeld's Facebook profile

The views expressed in this blog are mine and mine alone, not that of my employer, Microsoft, or anyone else’s. No warrantee is given for the quality of any material on this site.

Archives

Post Categories

WCF & Using Statements

I was attending the Dallas Connected Systems UG last night (http://biztalkusergroup.com/) and during the presentation I made the bold assertion that one should NOT use the "using statement" when working with WCF. Now I am a HUGE proponent of the using statement in normal circumstances. IMHO if it implements IDisposable use the using statement, except with WCF. This has to do with the way that WCF errors out and when that happens how the connection gets closed. . .

Doing my best LeVar Burton "But you don't have to take my word for it" (http://en.wikipedia.org/wiki/Reading_Rainbow). Microsoft even says it in the documentation, "You should not use the using statement (Using in Visual Basic) because it may mask exceptions in certain failure modes. " (http://msdn.microsoft.com/en-us/library/ms735103.aspx)

Also check out a post by Dan Rigsby that goes into more detail. http://www.danrigsby.com/blog/index.php/2008/02/26/dont-wrap-wcf-service-hosts-or-clients-in-a-using-statement/

Print | posted on Thursday, November 13, 2008 11:29 AM | Filed Under [ .NET C# SOA VB.NET WCF ]

Feedback

No comments posted yet.

Post Comment

Title  
Name  
Email
Url
Comment   
Please add 7 and 5 and type the answer here:

Powered by: