Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用带有多个绑定的ServiceHostFactory的WCF服务主机_Wcf_Factory_Nettcpbinding_Basichttpbinding_Servicehost - Fatal编程技术网

使用带有多个绑定的ServiceHostFactory的WCF服务主机

使用带有多个绑定的ServiceHostFactory的WCF服务主机,wcf,factory,nettcpbinding,basichttpbinding,servicehost,Wcf,Factory,Nettcpbinding,Basichttpbinding,Servicehost,我已经为IIS上的主机创建了WCF服务。 我使用ServiceHostFactory方法托管我的服务(使用Unity作为DI) 我希望通过HTTP和TCP使用多个绑定来承载我的服务 我试着给出基本地址,但不起作用。在使用HTTP架构注册服务时仍给我错误信息 下面的代码片段可能会给您一些建议和想法 public class MyServiceHostFactory : ServiceHostFactory { protected override ServiceHost CreateSer

我已经为IIS上的主机创建了WCF服务。 我使用ServiceHostFactory方法托管我的服务(使用Unity作为DI)

我希望通过HTTP和TCP使用多个绑定来承载我的服务

我试着给出基本地址,但不起作用。在使用HTTP架构注册服务时仍给我错误信息

下面的代码片段可能会给您一些建议和想法

public class MyServiceHostFactory : ServiceHostFactory
{
    protected override ServiceHost CreateServiceHost(
                                Type serviceType, Uri[] baseAddresses)
    {
        MyServiceHost serviceHost = new MyServiceHost(serviceType, baseAddresses);

        //configure container
        MyFactory.Register();

        return serviceHost;
    }
}
配置文件:

<system.serviceModel>    
<services>
  <service name="My.Service.MyService">
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:9000/MyService/"/>
        <add baseAddress="net.tcp://localhost:9001/MyService/"/>
      </baseAddresses>
    </host>
    <endpoint address="Question" binding="basicHttpBinding" contract="My.Contract.IQuestionContract" />
    <endpoint address="Answer" binding="basicHttpBinding" contract="My.Contract.IAnswerContract" />
    <endpoint address="Question" binding="netTcpBinding" contract="My.Contract.IQuestionContract" />
    <endpoint address="Answer" binding="netTcpBinding"  contract="My.Contract.IAnswerContract" />
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="MyServicebehavior">
      <serviceMetadata httpGetEnabled="True" httpsGetEnabled="True" />
    </behavior>
  </serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="True">
</serviceHostingEnvironment>

有人能告诉我可以做什么吗

重要的是, 是否可以使用带有多个绑定的ServiceHostFactory托管服务


如果是,有人能帮我吗?

我会尝试删除base net.tcp地址并在端点上指定完整地址。

我尝试在绑定中提供完整地址,但它不起作用。“没有与给定地址'net'匹配的协议绑定。tcp://localhost:9001/MyService/Question“你也试过删除基址吗?是的。我也删除了基址。”。