Ok, I manage my own App.Config. I don’t need a wizard to do it for me, thank you very much. And the code that it puts in my App.Config is verbose garbage. I am capable of writing my own WCF endpoints and bindings. I just want Visual Studio 2010 to do what it is best at doing: code generation. Just give me the server and data-contract code! Is there any way to turn this off? Is there a way to call ‘Update Service Reference’ without VS changing the App.Config? Its very frustrating. Now it gives me an exception unless I completely delete all of the endpoint nodes from my App.Config.
This is the exception that I get:
There was an error downloading
‘http://localhost:8732/MyService/mex’.The request failed with HTTP status 400: Bad Request.
A child element named ‘endpoint’ with same key already exists at the
same configuration scope. Collection elements must be unique within
the same configuration scope (e.g. the same application.config file).
Duplicate key value:
‘contractType:Web.DataService.MyService.IMyService;name:MyService.Live’.
(C:\ProjectPath\App.config line 152)
And here is my App.Config:
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="Binding.Debug" maxReceivedMessageSize="2147483647">
</binding>
<binding name="Binding.Secure" maxReceivedMessageSize="2147483647">
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<!-- Debug client endpoints -->
<endpoint name="MyService.Debug"
contract="Web.DataService.MyService.IMyService"
address="http://localhost:8732/MyService"
binding="wsHttpBinding"
bindingConfiguration="Binding.Debug"
/>
<endpoint name="MyService1.Debug"
contract="Web.DataService.MyService1.IMyService1"
address="http://localhost:8732/MyService1"
binding="wsHttpBinding"
bindingConfiguration="Binding.Debug"
/>
<endpoint name="MyService2.Debug"
contract="Web.DataService.MyService2.IMyService2"
address="http://localhost:8732/MyService2"
binding="wsHttpBinding"
bindingConfiguration="Binding.Debug"
/>
<endpoint name="MyService3.Debug"
contract="Web.DataService.MyService3.IMyService3"
address="http://localhost:8732/MyService3"
binding="wsHttpBinding"
bindingConfiguration="Binding.Debug"
/>
<!-- Local client endpoints -->
<endpoint name="MyService.Local"
contract="Web.DataService.MyService.IMyService"
address="https://www.mydomain.com/MyVirtualDirectory.Local/MyService.svc"
binding="wsHttpBinding"
bindingConfiguration="Binding.Secure"
/>
<endpoint name="MyService1.Local"
contract="Web.DataService.MyService1.IMyService1"
address="https://www.mydomain.com/MyVirtualDirectory.Local/MyService1.svc"
binding="wsHttpBinding"
bindingConfiguration="Binding.Secure"
/>
<endpoint name="MyService2.Local"
contract="Web.DataService.MyService2.IMyService2"
address="https://www.mydomain.com/MyVirtualDirectory.Local/MyService2.svc"
binding="wsHttpBinding"
bindingConfiguration="Binding.Secure"
/>
<endpoint name="MyService3.Local"
contract="Web.DataService.MyService3.IMyService3"
address="https://www.mydomain.com/MyVirtualDirectory.Local/MyService3.svc"
binding="wsHttpBinding"
bindingConfiguration="Binding.Secure"
/>
<!-- Beta client endpoints -->
<endpoint name="MyService.Beta"
contract="Web.DataService.MyService.IMyService"
address="https://www.mydomain.com/MyVirtualDirectory.Beta/MyService.svc"
binding="wsHttpBinding"
bindingConfiguration="Binding.Secure"
/>
<endpoint name="MyService1.Beta"
contract="Web.DataService.MyService1.IMyService1"
address="https://www.mydomain.com/MyVirtualDirectory.Beta/MyService1.svc"
binding="wsHttpBinding"
bindingConfiguration="Binding.Secure"
/>
<endpoint name="MyService2.Beta"
contract="Web.DataService.MyService2.IMyService2"
address="https://www.mydomain.com/MyVirtualDirectory.Beta/MyService2.svc"
binding="wsHttpBinding"
bindingConfiguration="Binding.Secure"
/>
<endpoint name="MyService3.Beta"
contract="Web.DataService.MyService3.IMyService3"
address="https://www.mydomain.com/MyVirtualDirectory.Beta/MyService3.svc"
binding="wsHttpBinding"
bindingConfiguration="Binding.Secure"
/>
<!-- Live client endpoints -->
<endpoint name="MyService.Live"
contract="Web.DataService.MyService.IMyService"
address="https://www.mydomain.com/MyVirtualDirectory/MyService.svc"
binding="wsHttpBinding"
bindingConfiguration="Binding.Secure"
/>
<endpoint name="MyService1.Live"
contract="Web.DataService.MyService1.IMyService1"
address="https://www.mydomain.com/MyVirtualDirectory/MyService1.svc"
binding="wsHttpBinding"
bindingConfiguration="Binding.Secure"
/>
<endpoint name="MyService2.Live"
contract="Web.DataService.MyService2.IMyService2"
address="https://www.mydomain.com/MyVirtualDirectory/MyService2.svc"
binding="wsHttpBinding"
bindingConfiguration="Binding.Secure"
/>
<endpoint name="MyService3.Live"
contract="Web.DataService.MyService3.IMyService3"
address="https://www.mydomain.com/MyVirtualDirectory/MyService3.svc"
binding="wsHttpBinding"
bindingConfiguration="Binding.Secure"
/>
</client>
</system.serviceModel>
This is very frustrating!
Edits:
I’ve figured out the exception that I was getting. I had MyService2.Live twice. I fixed this and no longer get the exception. I’d still like to know if I can keep VS10 from changing my App.Config.
You could use the svcutil tool to generate the files and manually merge them with the ones you have modified.
p.s: use slsvcutil if your client is Silverlight