Q:

WCF Exception Handaling

I have five separate services where each one corresponds to a different database table such as Product, User, Orders etc.
I am trying to send my custom exceptions across WCF. I have browsed the internet and i have wrapped my custom exceptions inside a fault exception:
interface
[FaultContract(typeof(NoSuchInstanceException))] 

cs
throw new FaultException<NoSuchInstanceException>(e, new FaultReason(e.Message), newFaultCode("UserFault"));

The problem is when i update the service the client proxy disappears. I browsed the internet and found the following solution which says to add a mapping to the service reference SVCMAP file. http://travisspencer.com/blog/2007/11/
<NamespaceMapping
    TargetNamespace="http://schemas.datacontract.org/2004/07/MyCompany.MyProject.Exceptions" ClrNamespace="MyCompany.MyProject.Exceptions" />
</NamespaceMappings>

My problem is that every service needs the custom exceptions adding to the mapping but when i do this. An error is displayed saying the exception is already defined in one of the other services. Do i merge the services into one service? Any help is really appreciated. Thanks

A:

I can think of two options:

Merge the services into one - having multiple services sharing the same data types gives this problem on the client.
Move the shared data types into a separate dll (class library project). Then reference that shared data type library from both your server and client. When you create the services reference, choose the option to reuse data types.

