使用NetTcpBinding的WCF服务库

我在使用NetTcpBinding时遇到了困难。

当我运行我的WCF服务时,我得到了这个:

System.InvalidOperationException: Could not find a base address that matches scheme net.tcp for the endpoint with binding NetTcpBinding. Registered base address schemes are [http]. at System.ServiceModel.ServiceHostBase.MakeAbsoluteUri(Uri relativeOrAbsoluteUri, Binding binding, UriSchemeKeyedCollection baseAddresses) at System.ServiceModel.Description.ConfigLoader.LoadServiceDescription(ServiceHostBase host, ServiceDescription description, ServiceElement serviceElement, Action`1 addBaseAddress) at System.ServiceModel.ServiceHostBase.LoadConfigurationSectionInternal(ConfigLoader configLoader, ServiceDescription description, ServiceElement serviceSection) at System.ServiceModel.ServiceHostBase.LoadConfigurationSectionInternal(ConfigLoader configLoader, ServiceDescription description, String configurationName) at System.ServiceModel.ServiceHostBase.ApplyConfiguration() at System.ServiceModel.ServiceHostBase.InitializeDescription(UriSchemeKeyedCollection baseAddresses) at System.ServiceModel.ServiceHost.InitializeDescription(Type serviceType, UriSchemeKeyedCollection baseAddresses) at System.ServiceModel.ServiceHost..ctor(Type serviceType, Uri[] baseAddresses) at Microsoft.Tools.SvcHost.ServiceHostHelper.CreateServiceHost(Type type, ServiceKind kind) at Microsoft.Tools.SvcHost.ServiceHostHelper.OpenService(ServiceInfo info) 

当我使用WCFSvcHost默认运行应用程序时,我得到了这个。 没有额外的代码。只需要任何新的wcf服务的默认代码。 我想做的就是将绑定更改为tcp。

我该如何解决这个问题?

编辑:这是我的WCF的App.config

                                            

在这个部分

      

添加net.tcp://基地址。

       

我相信你现在已经解决了这个问题,但它确实与baseAddresses无关,这就是所有bullentin板引导你的。 我在http://social.msdn.microsoft.com/forums/en-US/wcf/thread/c9f8d99d-89ee-4573-8528-a21b047bad11找到了答案。 假设您使用的是IIS 7.x:右键单击IIS中的虚拟目录/应用程序,选择“管理应用程序” – >“高级设置”。 在’Enabled Protocols’部分中添加net.tcp,例如:http,net.tcp。 即使您已在站点级别添加此协议,这也是必需的。

你可以共享端口,这不是太难。

确保在IIS中选择启用的协议(右键单击站点 – >管理网站 – >高级设置),不要使用空间。 如果你有“http,net.tcp”而不是“http,net.tcp”它将无法正常工作,而是给你这个确切的错误。

更多信息请访问: http : //www.weeksofprogramming.com/post/Could-not-find-a-base-address-Check-for-spaces-in-IIS7.aspx

在IIS站点中配置net.tcp绑定,并将启用的协议设置为“http,net.tcp using advanced setting”。它应该工作

  1. validation计算机上是否已启动Net.Tcp端口共享服务
  2. validation配置netTcpBinding portSharingEnabled属性是否为true。 (在WCF4中,如果要将此绑定规范作为net.tcp的缺省值,则无需在绑定元素上提供名称)