找不到名称为WCF的端点元素

时间:2015-02-12 10:50:42

标签: c#

我将名称发送到端点但我收到错误。

错误:

无法找到名称为“HTTP_Port”的端点元素,并在ServiceModel客户端配置部分中收缩“WSPI.InvoiceCheck_Out”。这可能是因为没有为您的应用程序找到配置文件,或者因为在客户端元素中找不到与此名称匹配的端点元素。

enter image description here

WebConfig:

<client>
            <endpoint address="https://example.company.eu:51201"
                binding="basicHttpBinding" bindingConfiguration="InvoiceCheck_OutBinding"
                contract="WSPI.InvoiceCheck_Out" name="HTTP_Port" />
            <endpoint address="https://example.company.eu:51201"
                binding="basicHttpBinding" bindingConfiguration="InvoiceCheck_OutBinding1"
                contract="WSPI.InvoiceCheck_Out" name="HTTPS_Port" />
</client>

我把这个工作正确 App.config

<?xml version="1.0"?>
<configuration>
  <startup>
    <supportedRuntime version="v2.0.50727"/>
  </startup>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.SharePoint" publicKeyToken="71E9BCE111E9429C" culture="neutral"/>
        <bindingRedirect oldVersion="0.0.0.0-14.0.0.0" newVersion="14.0.0.0"/>
      </dependentAssembly>
    </assemblyBinding>

  </runtime>
    <system.serviceModel>
      <bindings>
        <basicHttpBinding>
          <binding name="InvoiceCheck_OutBinding" />
          <binding name="InvoiceCheck_OutBinding1">
            <security mode="Transport" />
          </binding>
        </basicHttpBinding>
      </bindings>
      <client>
        <endpoint address="http://test"
            binding="basicHttpBinding" bindingConfiguration="InvoiceCheck_OutBinding"
            contract="WSPI.InvoiceCheck_Out" name="HTTP_Port" />
        <endpoint address="https://test"
            binding="basicHttpBinding" bindingConfiguration="InvoiceCheck_OutBinding1"
            contract="WSPI.InvoiceCheck_Out" name="HTTPS_Port" />
      </client>
    </system.serviceModel>
</configuration>

1 个答案:

答案 0 :(得分:3)

因为您将此代码作为dll引用,所以您的代码将检查您的应用程序(在您的情况下是您的控制台应用程序),它正在引用它以进行配置。尝试从您的dll中获取<System.ServiceModel>配置,并将其添加到适用于您的控制台应用程序的app.config中。