Question

I have 2 WCF services (different projects) sharing a class library with a MyExceptions defined.

Both services uses:

[OperationContract]
[FaultContract(typeof(MyException))]
void op();

When I add both references in the client project I get:

Type namespace.MyException already defines a member called MyException with the same parameter types.

Basically the classes has the same name so the constructor is defined twice. Any Idea of how to change the Exception namespace?

Please note that:

  • I am using svcutils
  • the namespace option doesn't work.

Thanks

Was it helpful?

Solution

Create the proxy using svcutil /reference:SharedLibrary.dll. This way svcutil won't generate classes that it finds in the SharedLibrary.dll, so the client uses the class definitions from the assembly.

Don't forget to add a reference to the DLL in the client project, if you haven't already done so.

OTHER TIPS

Besides the namespace suggestion what can be done is to edit the proxy code generated by SVCUTIL and remove the duplicate code for the MyException class.

The steps: 1. Create a proxy file for Service1. 2. Create a proxy file for Service2. 3. Add the proxies to the client. 4. Compile and it gives error for having MyException already being declared. 5. Edit either one of the proxies and remove the MyException class code.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top