【问题标题】:Could not find default endpoint element that references contract 'LDServiceHost.ILDService' in the ServiceModel client configuration section在 ServiceModel 客户端配置部分中找不到引用合同“LDServiceHost.ILDService”的默认端点元素
【发布时间】:2011-11-01 02:49:05
【问题描述】:

错误:

找不到引用合约的默认端点元素 ServiceModel 客户端配置中的“LDServiceHost.ILDService” 部分。这可能是因为找不到配置文件 您的应用程序,或者因为没有与此匹配的端点元素 合同可以在客户端元素中找到。

App.Config:

    <?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
  </configSections>
  <system.diagnostics>
    <sources>
      <source name="System.ServiceModel" switchValue="Warning, ActivityTracing"
          propagateActivity="true">
        <listeners>
          <add type="System.Diagnostics.DefaultTraceListener" name="Default">
            <filter type="" />
          </add>
          <add name="ServiceModelTraceListener">
            <filter type="" />
          </add>
        </listeners>
      </source>
      <source name="System.ServiceModel.MessageLogging" switchValue="Warning, ActivityTracing">
        <listeners>
          <add type="System.Diagnostics.DefaultTraceListener" name="Default">
            <filter type="" />
          </add>
          <add name="ServiceModelMessageLoggingListener">
            <filter type="" />
          </add>
        </listeners>
      </source>
    </sources>
    <sharedListeners>
      <add initializeData="C:\_Demos\EF Code Samples\EFLayers\LDPresentation\app_tracelog.svclog"
          type="System.Diagnostics.XmlWriterTraceListener, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
          name="ServiceModelTraceListener" traceOutputOptions="Timestamp">
        <filter type="" />
      </add>
      <add initializeData="C:\_Demos\EF Code Samples\EFLayers\LDPresentation\app_messages.svclog"
          type="System.Diagnostics.XmlWriterTraceListener, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
          name="ServiceModelMessageLoggingListener" traceOutputOptions="Timestamp">
        <filter type="" />
      </add>
    </sharedListeners>
    <trace autoflush="true" />
  </system.diagnostics>



    <system.serviceModel>
        <bindings>
            <wsHttpBinding>
                <binding name="WSHttpBinding_ILDService" closeTimeout="00:01:00"
                    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                    bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
                    maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                    messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
                    allowCookies="false">
                  <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                      maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                  <reliableSession ordered="true" inactivityTimeout="00:10:00"
                      enabled="false" />
                  <security mode="Message">
                    <transport clientCredentialType="Windows" proxyCredentialType="None"
                        realm="" />
                    <message clientCredentialType="Windows" negotiateServiceCredential="true"
                        algorithmSuite="Default" establishSecurityContext="true" />
                  </security>
                </binding>
            </wsHttpBinding>
        </bindings>

      <diagnostics>
        <messageLogging logMalformedMessages="true" logMessagesAtTransportLevel="true" />
      </diagnostics>

        <client>
            <endpoint address="http://localhost:8732/Design_Time_Addresses/LibraryService/LDService/"
                binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_ILDService"
                contract="LDServiceHost.ILDService" name="WSHttpBinding_ILDService">
                <identity>
                    <dns value="localhost" />
                </identity>
            </endpoint>
        </client>
    </system.serviceModel>
</configuration>

如何解决?

【问题讨论】:

  • 创建服务代理时是否传入端点名称WSHttpBinding_ILDService?你能发布你的客户端代码的那部分吗?

标签: wcf visual-studio-2010 service


【解决方案1】:

您的配置位于库项目中。配置文件是应用程序而不是 .NET 中特定的库,因此配置需要在 .exe 中而不是在 DLL 中

将您的 DLL 配置的 system.serviceModel 部分复制到您的应用程序的配置文件中,它应该可以找到它

顺便说一句:通常最好将问题全部放在一个地方而不是添加到外部站点的链接 - 这些有与 SO 不同步的习惯,因此问题最终没有多大意义

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-11-08
    • 2014-10-11
    • 1970-01-01
    • 2022-06-13
    • 1970-01-01
    • 2012-03-11
    • 1970-01-01
    • 2011-01-12
    相关资源
    最近更新 更多