SonOfPirate
SonOfPirate

Reputation: 5494

Have Visual Studio share a namespace with multiple service references

Is there any way possible short of hand-coding the Reference.cs file, to get Visual Studio to allow multiple service references to share a namespace?

I am developing a client application that makes use of several services that are part of the same solution. Something along the lines of the Project Service Interface (PSI) API Microsoft has for MS-Project Server. Rather than have a different namespace for each individual service reference, such as:

MyProject.ProjectService.ProjectServiceClient
MyProject.ResourceService.ResourceServiceClient
MyProject.TimesheetService.TimesheetServiceClient

it would be nice if we could throw them all into a single namespace, like:

MyProject.Services.ProjectServiceClient
MyProject.Services.ResourceServiceClient
MyProject.Services.TimesheetServiceClient

Along with this comes the ability to share common code. For instance if any of these services exposed the same data contract. Right now, if I want to write code that my client can use I have to create a separate version for each service proxy because the common contract exists in three different namespaces. See where I'm going?

It is possible?

UPDATE

Let's assume that I don't have access to the service code (cuz I don't) which means that a shared class library is not an option. What are my choices in this case?

Upvotes: 5

Views: 1846

Answers (1)

John Saunders
John Saunders

Reputation: 161791

You can place these common classes into a class library which is shared by both the services and the clients. Then, Visual Studio will not generate classes for each service reference, but will instead use the common class library.

Upvotes: 1

Related Questions