Thursday, June 12, 2008

XML Documentation Guide

Whenever you need to document your .NET code (and don't remember all the possibe XML tags), here's a guide describing the tags. http://dynicity.com/products/XMLDocComments.aspx

Monday, June 9, 2008

Using statement and the WCF proxy

When you implement the closing of a WCF proxy with the 'using' statement, be aware that in some conditions exceptions can be lost. Example:
try { using (MyProxy proxy = new MyProxy()) { proxy.SomeOperation(); } } catch (Exception ex) { ..... }
If the call to the service operation results in 'faulting' the channel, the original exception will be lost because leaving the using block will trigger a call to the Close method on the proxy, resulting in another exception (telling you that the channel is faulted) which masks the original exception. The annoying thing is that the behaviour of this code is dependent on the type of binding used (e.g. with a basicHttpBinding everything goes well, with a wsHttpBinding the real exception is masked when the channel is faulted). You can come up with different solutions for this problem. Some examples: - Keep the using statement and embed each call to an operation in it's own try..catch statement. - Replace the using statement with a try..finally construction, where you check the channel status in the finally clause. If the channel is faulted, you can call the Abort method instead of the Close method.