C# 正在使用添加服务引用将服务引用添加到NetTcp服务。。。对话

C# 正在使用添加服务引用将服务引用添加到NetTcp服务。。。对话,c#,wcf,C#,Wcf,我定义了一个服务。App.config中的服务模型节点是: <system.serviceModel> <bindings> <netTcpBinding> <binding name="NetTcpBindingConfiguration"> <security mode="None" /> </binding>

我定义了一个服务。App.config中的服务模型节点是:

<system.serviceModel>
    <bindings>
        <netTcpBinding>
            <binding name="NetTcpBindingConfiguration">
                <security mode="None" />
            </binding>
        </netTcpBinding>
    </bindings>
    <services>
        <service name="Products.ProductsServiceImpl">
            <endpoint address="net.tcp://localhost:8080/Whatever" binding="netTcpBinding"
                bindingConfiguration="NetTcpBindingConfiguration" name="NetTcpBinding_IProductsService"
                contract="Products.IProductsService" />
        </service>
    </services>
</system.serviceModel>
我使用了一个WCF库来创建服务(定义了服务和合同))

明白了

我用了这个博客:

  • “mex”端点应使用“mexTcpBinding”
  • 必须定义主机基址,并将主端点地址留空
  • httpGetEnabled设置为false
  • 下面是完整的服务模型节点(App.config)

    虽然如果您已经启动了服务,但在“添加服务引用…”中按Go键时,如果您还没有启动,它会为您添加mex文本

    Security mode=“none”用于从网络的其他机器访问服务


    愉快的编码。

    您是否尝试在端点公开元数据交换的mextcpbinding。对不起,我是新手,我该怎么做?请……我已经提到我按照WCF NetCp中的建议做了。。。发帖没有成功。我添加了行为,添加了带有“mex”地址的新端点,但在运行和尝试启动服务时,我收到一个错误,指出在服务实现的契约列表中找不到契约名称IMEADATAEXchange。我注意到该行为有一个名称“metadataSupport”,但从未使用过。我不知道在哪里使用它
    var productsServiceHost = new ServiceHost(typeof(ProductsServiceImpl));
    productsServiceHost.Open();
    stop.IsEnabled = true;
    start.IsEnabled = false;
    status.Text = "Service Running";
    
    <system.serviceModel>
        <bindings>
            <netTcpBinding>
                <binding name="NetTcpBindingConfiguration">
                    <security mode="None" />
                </binding>
            </netTcpBinding>
        </bindings>
        <services>
            <service name="Products.ProductsServiceImpl" behaviorConfiguration="metadataSupport">
                <endpoint address="" binding="netTcpBinding"
                    bindingConfiguration="NetTcpBindingConfiguration" name="NetTcpBinding_IProductsService" 
                    contract="Products.IProductsService" />
                <endpoint name="MetaDataTcpEndpoint"
                          address="mex"
                          binding="mexTcpBinding"
                          contract="IMetadataExchange"/>
                <host>
                    <baseAddresses>
                        <add baseAddress="net.tcp://localhost:8080/Whatever" />
                    </baseAddresses>
                </host>
            </service>
        </services>
        <behaviors>
            <serviceBehaviors>
                <behavior name="metadataSupport">
                    <serviceMetadata httpGetEnabled="false" />
                </behavior>
            </serviceBehaviors>
        </behaviors>
    </system.serviceModel>
    
    net.tcp://localhost:8080/Whatever/mex