Shared Data Contracts
When adding a service reference in Visual Studio 2010, you must provide a unique
namespace for each service reference. The imported types will be defined in that new
namespace. This presents a problem when adding references for two different services
that share the same data contract, since you will get two distinct types in two different
namespaces representing the same data contract.
By default, however, if any of the assemblies referenced by the client has a data contract type that matches a data contract type already exposed in the metadata of the referenced service, Visual Studio 2010 will not import that type again. It is worth emphasizing again that the existing data contract reference must be in another referenced assembly, not in the client project itself. This limitation may be addressed in a future release of Visual Studio, but for now, the workaround and best practice is obvious: factor all of your shared data contracts to a designated class library, and have all clients reference that assembly.
from "Ch 3. Data Contract at Programming WCF Services 3rd Ed"
namespace for each service reference. The imported types will be defined in that new
namespace. This presents a problem when adding references for two different services
that share the same data contract, since you will get two distinct types in two different
namespaces representing the same data contract.
By default, however, if any of the assemblies referenced by the client has a data contract type that matches a data contract type already exposed in the metadata of the referenced service, Visual Studio 2010 will not import that type again. It is worth emphasizing again that the existing data contract reference must be in another referenced assembly, not in the client project itself. This limitation may be addressed in a future release of Visual Studio, but for now, the workaround and best practice is obvious: factor all of your shared data contracts to a designated class library, and have all clients reference that assembly.
from "Ch 3. Data Contract at Programming WCF Services 3rd Ed"
댓글
댓글 쓰기