views:

63

answers:

3

In one Visual Studio solution, I have several projects. A couple of them access a certain web service. How can I add a service reference once, and have it used by both projects? I do not want to create an extra assembly for the sole purpose of providing access to the web service.

+2  A: 

Without creating a special project just for the web service, i don't think that is possible. You would need to add a service reference for each project that needs direct access to the service.

Jason Miesionczek
+1  A: 

You have to add the reference to the service in each project that references the project. When the reference is set a service proxy class is auto-generated that represents the web service in the project that references it.

Achilles
A: 

The service reference setup is actually stored in the project file; so, this isn't really viable and it's not any different from both projects referencing a common assembly.

The only "option" I can think of is if project B has a reference to Project A and Project A has the web reference to your web service, then B can call A which calls the Web Service.... But that only serves to hide your dependency.

This doesn't exactly sound like a problem worth solving. Especially if the two projects can be deployed independently.

Chris Lively
It is different from having both projects referencing a common assembly, in that Studio adds 30 files to my filesystem, mostly .datasource files. Presumably I need to check all of these into source control. If you have any insight into which files are essential, maybe I could get away with only checking in some of them, as long as Studio regenerates the rest upon a build.It is not a big problem, as you said, but it just seems silly to litter source control with all of those generated files, twice.
Jeremy Frank