ExceptionShielding Best Practice ?

Topics: General Discussion Forum
Jan 23, 2007 at 4:42 PM
We are checking the ExceptionShielding model used in the WCF Reference Implementation to figure out what is the suggested way to do it. In RI you defined the ExceptionShielding attribute and applied it on the ServiceContract (SC) and this means that all ServiceBehavior (SB) implementing this SC will always follow the policy defined.

Initially we thought that it was more logical applying this attribute on the SB to be able to have different implementation with different ExceptionShielding policy enabled.

Is applying attribute at interface level mandatory for some particular issue ? What is the best way (SC or SB) in your opinion ?


Jan 26, 2007 at 9:37 PM

You may use the ESH attribute at the SC level whenever you want your contract to adhere a particular exception shielding policy so all your implementations that use that contract will always honor that policy. On the other hand, if you want to use a particular policy per implementation (regardless of the contract), and then you may use the attribute at the SB level. My suggestion is to use the SC approach whenever possible since you are "binding" the contract with the shielding policy and therefore you make sure that any implementation that use that contract will always use a particular policy. Nevertheless you have the SB strategy for those scenarios that may require a different policy on each implementation.