对此已经有很多问题,但在其他情况下,似乎人们正试图拥有多个端点。就我而言,我只有一个并且只想要一个端点。仅当我启用证书传输安全性并且仅在我的开发计算机上才会出现我的错误。
我有一个通过 MVC 中的 ServiceRoute 实现的 WCF 服务:
RouteTable.Routes.Add(new ServiceRoute("MyServices", new WebServiceHostFactory(), typeof(MyServices)));
整个 serviceModel 仅包含以下内容:
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
<standardEndpoints>
<webHttpEndpoint>
<standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true">
<!--<security mode="Transport">
<transport clientCredentialType="Certificate" />
</security>-->
</standardEndpoint>
</webHttpEndpoint>
</standardEndpoints>
</system.serviceModel>
当运输安全被注释掉时,它工作正常。取消注释传输安全会导致:
A binding instance has already been associated to listen URI 'https://my.dev.machine.local/MyServices'. If two endpoints want to share the same ListenUri, they must also share the same binding object instance. The two conflicting endpoints were either specified in AddServiceEndpoint() calls, in a config file, or a combination of AddServiceEndpoint() and config.
我可以获取代码并将其放在不同的环境中,它可以按预期工作。怎么回事?!?