WCF: Updating Service Reference gives duplicate config entries
Asked Answered
L

4

5

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?

Lederer answered 9/12, 2009 at 10:37 Comment(0)
M
3

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

Macdermot answered 28/12, 2009 at 8:34 Comment(0)
G
2

code-zoop says that this known bug is resolved in VS2010, but I'm getting it in VS2010 as well.

Happens when I manually modify the default value for the MaxReceivedMessageSize property (and others) of the basicHttpBinding in App.config (as per this post: WCF - How to Increase Message Size Quota)

Just thought I'd mention that this happens in VS2010 as well. For the moment, I'm taking Shiraz Bhaiji's advice and just deleting the duplicate, which seems to be working for the moment being.

Greenbrier answered 12/4, 2011 at 9:26 Comment(1)
And me: #4626243Dairying
M
1

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.

Moneyed answered 10/12, 2009 at 20:32 Comment(1)
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?..Lederer
H
1

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

Hayner answered 30/9, 2010 at 4:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.