C# 具有NetTcpBinding的WCF服务库
我和内特相处得很艰难 当我运行我的WCFservice时,我得到以下信息:C# 具有NetTcpBinding的WCF服务库,c#,.net,wcf,wcf-binding,C#,.net,Wcf,Wcf Binding,我和内特相处得很艰难 当我运行我的WCFservice时,我得到以下信息: 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.Servi
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
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<compilation debug="true" />
</system.web>
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="tcpBinding" transferMode="Streamed" portSharingEnabled="false">
<reliableSession enabled="true" />
<security mode="None">
<transport clientCredentialType="None" protectionLevel="None" />
<message clientCredentialType="None" />
</security>
</binding>
</netTcpBinding>
</bindings>
<services>
<service behaviorConfiguration="WcfServiceLibrary1.Service1Behavior"
name="WcfServiceLibrary1.Service1">
<endpoint address="" binding="wsHttpBinding" contract="WcfServiceLibrary1.IService1">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<endpoint address="Service" binding="netTcpBinding" bindingConfiguration="tcpBinding"
name="testTcp" contract="WcfServiceLibrary1.IService1" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8731/Design_Time_Addresses/WcfServiceLibrary1/Service1/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="WcfServiceLibrary1.Service1Behavior">
<serviceMetadata httpGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
本节中的
<host>
<baseAddresses>
<add baseAddress="http://localhost:8731/.../" />
</baseAddresses>
</host>
添加一个net.tcp://基址
<host>
<baseAddresses>
<add baseAddress="http://localhost:8732/" />
<add baseAddress="net.tcp://localhost"/>
</baseAddresses>
</host>
我相信您现在已经解决了这个问题,但它实际上与baseAddresses无关,而baseAddresses正是所有bullentin板引导您解决的问题。我找到了答案。假设您使用的是IIS 7.x:右键单击IIS中的虚拟目录/应用程序,选择管理应用程序->高级设置。在“启用的协议”部分添加net.tcp,例如:http,net.tcp。即使您已经在站点级别添加了此协议,这也是必需的
在IIS站点中配置net.tcp绑定,并将启用的协议设置为“http,net.tcp使用高级设置”。它应该可以工作您可以共享端口,这并不难 确保在IIS中选择启用的协议时(右键单击站点->管理网站->高级设置),不使用空格。如果您使用“http,net.tcp”而不是“http,net.tcp”,那么它将不起作用,而是会给出这个确切的错误
此处的更多信息:您能从app/web.config发布您的WCF配置吗?即使我发布了配置,它也不可见添加后,请按“代码”按钮(将每行缩进4个空格,而不解释xml)明白了…谢谢…没有意识到这个事实适用于XML:)添加不起作用。它说端口正在使用中,有点错误。你能帮我填一下那行吗?ThanksSystem.ServiceModel.AddressalReadyUseException:TransportManager未能使用NetCpPortShared服务侦听提供的URI:该服务未能侦听。请确保使用其他端口(例如,如果http位于8731上,则使用8732:net)。tcp://localhost:8732/Yadda/Blah/ )我无法使用多个端口,因为我计划在已部署的asp.net应用程序上使用它。我正在尝试net.tcp共享…但它也失败了。我在另一个问题上问了这个错误。。我在app.config中看到portSharingEnabled=false。也就是说,我不知道你是否可以像那样共享http和tcp(不记得了)。我看到你的绑定中也将安全模式设置为“无”,这是我开始使用的,但是,对于我正在做的事情,我需要知道经过身份验证的调用方。我通常从OperationContext.Current.ServiceSecurityContext.PrimaryIdentity.Name()获取此信息。因此,我根据(Windows身份验证的传输安全性)将客户端和服务器上的绑定都更改为Windows?有什么想法吗?谢谢你。。。我已经盯着这个配置文件看了大约2个小时了,我不知道到底发生了什么……是的,是的,一千次了;我忘了做这件事,因为我确信我不需要提供一个基本地址,所以我在试图弄清楚我必须改变什么时很不愉快。