Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/21.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.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
C# 在所有脚本中找不到默认终结点元素错误_C#_.net_Wcf - Fatal编程技术网

C# 在所有脚本中找不到默认终结点元素错误

C# 在所有脚本中找不到默认终结点元素错误,c#,.net,wcf,C#,.net,Wcf,我想连接到WCF服务。服务引用驻留在类库中。通过向单元测试项目添加App.config,我成功连接到MSTEST单元测试中的服务。我无法连接到应用程序中的服务。我找到了应用程序的配置文件。我可以编辑该文件,并确认我可以通过访问添加到配置中的密钥 出现此问题是因为客户端配置中没有与ContractName.Service名称匹配的端点 我所看到的是,您只有一个端点与另一个合同公司namepingenerator.IPinGenerator 位于代理文件中的服务类或接口引用了ContractName

我想连接到WCF服务。服务引用驻留在类库中。通过向单元测试项目添加App.config,我成功连接到MSTEST单元测试中的服务。我无法连接到应用程序中的服务。我找到了应用程序的配置文件。我可以编辑该文件,并确认我可以通过访问添加到配置中的密钥


出现此问题是因为客户端配置中没有与ContractName.Service名称匹配的端点

我所看到的是,您只有一个端点与另一个合同公司namepingenerator.IPinGenerator

位于代理文件中的服务类或接口引用了ContractName.service,而配置中缺少它

您必须确保以下几点:

将生成的代理更新为最新版本 确保客户端配置包含服务所需的所有端点。
通常当我面对这样的问题时,我打开VS命令提示符运行svcuti.exe,并从生成的文件中复制代理代码和客户端配置。

右侧建议了几个相关主题,这些主题可能有助于解决此问题。您确定端点的contract属性中包含CompanyNamePinGenerator.IPinGenerator吗完全正确吗?并且您提供的确切地址处的服务器端终结点是basicHttpBinding?如果还没有system.serviceModel节,则将整个节从mstest app.config复制到应用程序的配置文件中应该足以使事情正常工作。我建议使用SvcConfigEditor.exe打开您的配置文件验证对绑定和配置的各种引用是否正确。
<system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="BasicHttpBinding_IPinGenerator" closeTimeout="00:01:00"
                 openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                 allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                 maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                 messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                 useDefaultWebProxy="true">
                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                     maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    <security mode="None">
                        <transport clientCredentialType="None" proxyCredentialType="None"
                         realm="" />
                        <message clientCredentialType="UserName" algorithmSuite="Default" />
                    </security>
                </binding>
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://somewhere"
             binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IPinGenerator"
             contract="CompanyNamePinGenerator.IPinGenerator" name="BasicHttpBinding_IPinGenerator" />
        </client>
    </system.serviceModel>