Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sharing classes between multiple WCF services

Tags:

c#

wcf

wcf-client

I have two WCF services, one for reading operations and the other one for writing operations.

Although they are doing different operations, both of them are sharing the same classes (through a DLL reference to other project wich supports the model of the problem).

My problem is that, when I try to add both services to my C# project I can't share the same namespace:

Cannot create a service reference with namespace 'X' because the name is already in use by an existing service reference, folder or file

If services are placed in different namespaces, classes are different and duplicated code grows a lot.

Is there any solution?

Edition: Very similar to: Two WCF services with different contracts but same business objects . No solution anyway.

like image 202
Jacob Avatar asked Sep 05 '26 16:09

Jacob


1 Answers

If you use VS 2010 (probably works on 2008 also) click advanced button in "add service reference" window and use "reuse types in specified referenced assemblies". You may have to move generated types to other assembly depending on how your project look like.

like image 110
pg0xC Avatar answered Sep 07 '26 06:09

pg0xC