簡體   English   中英

在WCF客戶端中找不到默認端點元素…

[英]Could not find default endpoint element … in WCF Client

我也在服務解決方案中創建了一個代理庫類,同時引用了合同程序集,並將庫(合同,代理)復制到另一個解決方案文件夾中。 然后引用另一個類庫中的Proxy,Contract和System.ServiceModel庫,在該類中,我需要使用其中包含的一個方法,並在該庫中添加App.Config。

該服務托管在Windows窗體應用程序中。 客戶端是一個從Windows窗體應用程序調用的類庫。我還沒有在Windows窗體項目中創建App.Config。 實際上,Windows Form項目將控件加載到庫中,而該控件加載需要使用service方法的庫。 所以我認為我應該只在最新程序集中引用(合同和代理),因為我不會在其他地方使用它。

但我不斷收到此錯誤:

在ServiceModel客戶端配置部分中找不到引用合同'Sign.Contracts.ISignDocument'的默認終結點元素。 這可能是因為沒有為您的應用程序找到配置文件,或者因為在客戶端元素中找不到與此合同匹配的端點元素。

libray中的App.Config調用代理:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.serviceModel>
    <services>
      <client>
        <endpoint
          address="http://localhost:8731/SignHere"
          binding="basicHttpBinding"
          contract="Sign.Contracts.ISignDocument" />
      </client>
    </services>
  </system.serviceModel>
</configuration>

服務主機中的App.Config:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.serviceModel>
    <services>
      <service name="Sign.Service.SignDocumentService">
        <endpoint 
          address="http://localhost:8731/SignHere" 
          binding="basicHttpBinding" 
          contract="Sign.Contracts.ISignDocument" />
      </service>
    </services>
  </system.serviceModel>
</configuration>

代理類:

namespace Sign.Proxies
{
    public class Proxy : ClientBase<ISignDocument>, ISignDocument
    {
        public string SignDocument(string document)
        {
            return Channel.SignDocument(document);
        }
    }
}

合同類:

namespace Sign.Contracts
{
    [ServiceContract]
    public interface ISignDocument
    {
        [OperationContract]
        string SignDocument(string document);
    }
}

有任何想法嗎?

任何程序都只有一個配置文件。 在您的情況下,這就是Winforms程序的app.config,在構建程序時它將復制到programName.exe.config。

任何WCF配置都必須在該文件中。 您的庫具有app.config的事實並不重要。 您需要從庫的app.config中復制相關的配置條目,並將它們與Winforms應用程序的app.config合並。

oo ...客戶端app.config中沒有客戶端終結點信息的父元素。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM