WCF service startup error “This collection already contains an address with scheme http”

后端 未结 7 1470
日久生厌
日久生厌 2020-12-02 04:06

I built a web application containing a WCF service contract and a Silverlight control which makes calls to that WCF service. On my development and test servers it works grea

7条回答
  •  生来不讨喜
    2020-12-02 05:01

    And in my case it was simple: I used 'Add WCF Service' wizard in Visual Studio, which automatically created corresponding sections in app.config. Then I went on reading How to: Host a WCF Service in a Managed Application. The problem was: I didn't need to specify the url to run the web service.

    Replace:

    using (ServiceHost host = new ServiceHost(typeof(HelloWorldService), baseAddress))
    

    With:

    using (ServiceHost host = new ServiceHost(typeof(HelloWorldService))
    

    And the error is gone.

    Generic idea: if you provide base address as a param and specify it in config, you get this error. Most probably, that's not the only way to get the error, thou.

提交回复
热议问题