【问题标题】:Could not find endpoint element with name WCF找不到名为 WCF 的端点元素
【发布时间】:2015-02-12 10:50:41
【问题描述】:

我将名称发送到端点,但出现错误。

错误:

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

网络配置:

<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>

【问题讨论】:

  • 您的代码是如何运行的?如果是在说控制台应用程序中,我认为没有问题。如果您的代码在运行时从另一个库(即插件)加载,那么这可能是您定位配置文件的问题
  • 我将其用作 .dll 进行测试。后来我从控制台应用程序调用它。

标签: c#


【解决方案1】:

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

【讨论】:

  • 感谢您的宝贵时间 :)
  • 我不明白答案。请@RafałDeveloper 详细解释一下。谢谢!
猜你喜欢
  • 2010-12-30
  • 1970-01-01
  • 2015-11-02
  • 1970-01-01
  • 1970-01-01
  • 2023-03-24
  • 1970-01-01
  • 2011-03-12
  • 1970-01-01
相关资源
最近更新 更多