[英]Could not find a base address that matches scheme net.tcp for the endpoint
I have a Wcf Service project. 我有一个Wcf服务项目。 system.serviceModel
tag in my web.config is : 我的web.config中的system.serviceModel
标记是:
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="RCISPNetTcpBinding" openTimeout="00:10:00" sendTimeout="00:10:00">
<security mode="Transport">
<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign">
</transport>
<message clientCredentialType="Windows"/>
</security>
</binding>
</netTcpBinding>
</bindings>
<services>
<service behaviorConfiguration="RCISP.WcfServiceBehaviour" name="RCISP.WcfService.PersonWcfService">
<endpoint address="PersonServices" binding="netTcpBinding" bindingConfiguration="RCISPNetTcpBinding"
contract="RCISP.Common.ServiceContract.IPersonService" >
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:40003/"/>
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="RCISP.WcfServiceBehaviour">
<serviceMetadata httpGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="false" />
<serviceAuthorization principalPermissionMode="UseWindowsGroups" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
I have a runtime error when I want create self-hosting for service. 当我想要为服务创建自托管时,我有一个运行时错误。
public class ServiceFactory : ServiceHostFactory
{
protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)
{
if (!IsInitialised) InitialiseService();
return base.CreateServiceHost(serviceType, baseAddresses);
}
}
Message of Exception is : 异常消息是:
Could not find a base address that matches scheme net.tcp for the endpoint with binding NetTcpBinding. Registered base address schemes are [http].
Why? 为什么?
You said you were self hosting the service (within your own process) but based on the code above I think you're trying to host it inside of a web application. 你说你是自己托管服务(在你自己的过程中),但根据上面的代码,我认为你试图在Web应用程序内托管它。 If so Visual Studio's web server can not host a net.tcp end point. 如果是这样,Visual Studio的Web服务器无法承载net.tcp端点。 You'll need to set the project up to run under IIS. 您需要将项目设置为在IIS下运行。 Please follow the instructions here . 请按照此处的说明操作。
If you are truly self hosting than you can leave the configuration exactly how you have it and spin up the service using the following code: 如果您真的是自托管,那么您可以完全按照配置保留配置,并使用以下代码启动服务:
var host = new ServiceHost(typeof(Service1));
host.Open();
You need to add a protocol mapping to your configuration file to tell it what the "net.tcp" protocol is. 您需要将协议映射添加到配置文件中,以告诉它“net.tcp”协议是什么。 Right after your <bindings>
section add this: 在<bindings>
部分之后添加以下内容:
<protocolMapping>
<add scheme="net.tcp" binding="netTcpbinding"/>
</protocolMapping>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.