3

I want to update service references in a Visual Studio 2010 solution by using SVCUtil because this solution has several projects and it's not good to get references refreshed one by one.

I'd like to know your point, because I've to be sure I'm going to execute exactly same command than one done by Visual Studio 2010, or even if Visual Studio 2010 doesn't use SVCUtil, an equivalent command to IDE's behavior.

Thank you very much.

Matías Fidemraizer
  • 63,804
  • 18
  • 124
  • 206

2 Answers2

3

The easiest way to refresh a lot of service references is to put all those in a dedicated project. Reference this project from all the projects that need to use them. If a service reference needs to be updated, you will do it in one place only.

Johann Blais
  • 9,389
  • 6
  • 45
  • 65
  • Right, I believe this is a good solution! Thank you! Anyway, problem is if you've a client-server infraestructure, you'd not be able to do that, because you don't want a project having dependencies to both tiers. – Matías Fidemraizer Sep 17 '10 at 12:03
1

Some googling here and here shows the settings on VS 2008, although this will depend of course on your options in the Advanced options in the Add Service Reference wizard.

From : http://geekswithblogs.net, Dave Barrett, 30 June 2008:

Contrary to Visual Studio 2005, the Add service reference command in Visual Studio 2008 does not use svcutil.exe, but rather it's own built-in functionality.

Using a comparison reference between the two and my own analysis of the results, I came up with the following command to mimic what the command does in VS 2008 (keep in mind a few of these options, such as the /ct and the /l switches, were specific to my situation):

svcutil *.wsdl *.xsd /l:C# /out:Reference.cs /noconfig /s 
        /ct:System.Collections.Generic.List`1 /ser:Auto /tcv:Version30 
        /n:*,<NameOfYourNamespaceHere> /edb

I ran this in the folder where the schema files (WSDL, XSD) were located from a VS2008 command line.

Edit : Agreed - Never be afraid to drop and recreate service references from scratch. When working with version control like TFS, "update" service references there is often quite a mess as it figures which wsdl, xsd and disco files etc have been changed, added or deleted etc (and get filenames like SomeXSD92.xsd). Generally it is quicker to just drop and recreate them.

Johan's post is makes a good point (and can be used as part of a standard design pattern called Service Agent which handles the implementation of the client proxy). I'm not quite sure what you mean when you say two tiers would need to reference the same assembly? If you are sharing type of the entities called in the service you would need to reference the entity assembly in most tiers anyway. For your Service Agent assembly project (which has all the service references) you can either re-expose the same Service Contract used by the WCF server or wrap it in a new interface.

StuartLC
  • 104,537
  • 17
  • 209
  • 285
  • Thank you for your answer. I'm not sure this is what I need for doing that reference update. I found before your first link, second one is a good info, but anyway, I don't want to "add service reference" but "update service reference". Maybe I'm wrong, but it's possible that updating is like dropping and re-creating all, isn't it? – Matías Fidemraizer Sep 16 '10 at 09:23
  • Sorry for my delay. I'm currently solving that with VS Automation (EnvDTE) which is more elegant and ensures service references are updated exactly by using same VS command raised from the UI. – Matías Fidemraizer Sep 22 '10 at 08:36