views:

305

answers:

3

I have a WPF application using service references to a WCF service. When doing updates on the service I need to update the service reference, so I right click it and hit "Update Service Reference".

Doing this results in duplicate entries in the App.config file of the client project.

  • It duplicates a binding under wsHttpBinding - adding an equal entry with postfix number in name: WSHttpBinding_ISomeService --> WSHttpBinding_ISomeService1.
  • And it duplicates the endpoint definition under binding such that there is one endpoint for each wsHttpBinding. This too is a pure duplicate except of the name.

Why does it duplicate the config? Isn't it just supposed to update the name? And how can I make it stop?

+1  A: 

This has also happend to us on a few occasions.

You need to remove the duplicate, otherwise it will crash at runtime. The client looks in the configuration file to find where it should send a request to Interface(WCF contract X), finds more than one, and crashes.

Shiraz Bhaiji
Yeah, I've seen that.. Can also set the binding name such that one specific binding is used, and hence the new ones added are ignored. But I'd like the duplicates not to be created - if possible.. Do you know why it happens? Any way to prevent it?..
stiank81
+2  A: 

Which version of Visual Studio are you using? This is a known bug, which has been fixed in VS2010. Check out this link!

code-zoop
Ah, that's it. Thanks! I'm using VS08..
stiank81
+1  A: 

one workaround is to put the service agent (web reference) in its own DLL and reference it from the main project.

it won't touch your service agent config in your web.config when you do Update Referene and as a bonus you'll have a project with up to date serviceagent config if you ever need to compare the default configuration with what you actually have in web.config

also has the benefit that if you have one service agent referencing another it will share the types

MAIN DLL > ServiceAgent1 DLL > ServiceAgent2 DLL

If ServiceAgent1 and ServiceAgent2 have shared types you won't get two generated duplicate classes

Simon_Weaver