Making slsvcutil behave like “Add Service Reference”

Just a quick note to clarify a subject where we get a lot of questions.

By default, running Add Service Reference against a WCF service and then running slsvcutil against that same service will not generate the same proxy. Some things that are different in the slsvcutil proxy include:

  • using arrays instead of ObservableCollection<T>
  • types don’t implement INotifyPropertyChanged for easy databinding
  • different namespace

To make slsvcutil generate the same proxy, use the following command. This is actually documented at the very bottom of the slsvcutil help text.

slsvcutil /edb /namespace:"*,SilverlightApplication1.ServiceReference1" /ct:System.Collections.ObjectModel.ObservableCollection`1 /r:"%PROGRAMFILES%\Reference Assemblies\Microsoft\Framework\Silverlight\v3.0\System.Windows.dll"

Hope this helps,

-Yavor Georgiev

Program Manager, WCF

Comments (1)

  1. Tony Pujals says:

    Thanks – came across the issue generating proxies for a Windows Phone 7 client. Add service reference doesn't work at all with the default System.Collections.ObjectModel.ObservableCollection checked (it works with System.Collections.ObjectModel.Collection) and you can't reuse any types in referenced assemblies.

    Using slsvcutil directly is the better solution — however, the help displays an error, which you copied above. %PROGRAMFILES% doesn't work; it needs to be %PROGRAMFILES(x86)% to find the correct Silverlight System.Windows.dll assembly.