简体   繁体   English

在WCF客户端中找不到默认端点元素…

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

I created a proxy Library Class in the Service Solution referencing the Contract Assembly as well and copied the libraries (Contract,Proxy) to another solution folder. 我也在服务解决方案中创建了一个代理库类,同时引用了合同程序集,并将库(合同,代理)复制到另一个解决方案文件夹中。 Then referenced the Proxy,Contract and System.ServiceModel libraries in another class library where i need to use the one method contained, as well as adding an App.Config inside the library. 然后引用另一个类库中的Proxy,Contract和System.ServiceModel库,在该类中,我需要使用其中包含的一个方法,并在该库中添加App.Config。

The Service is hosted in a windows forms application. 该服务托管在Windows窗体应用程序中。 The client is a class library called from a windows forms application.I haven't created an App.Config inside the windows form project. 客户端是一个从Windows窗体应用程序调用的类库。我还没有在Windows窗体项目中创建App.Config。 In fact the Windows Form project loads a control in a library and the control loads the library where i need to use the service method. 实际上,Windows Form项目将控件加载到库中,而该控件加载需要使用service方法的库。 So i thought i should only reference the (Contract and proxy) in the latest assembly since i wont use it anywhere else. 所以我认为我应该只在最新程序集中引用(合同和代理),因为我不会在其他地方使用它。

But i keep getting this error: 但我不断收到此错误:

Could not find default endpoint element that references contract 'Sign.Contracts.ISignDocument' in the ServiceModel client configuration section. 在ServiceModel客户端配置部分中找不到引用合同'Sign.Contracts.ISignDocument'的默认终结点元素。 This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element. 这可能是因为没有为您的应用程序找到配置文件,或者因为在客户端元素中找不到与此合同匹配的端点元素。

App.Config in libray calling the proxy: 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 in service Host: 服务主机中的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>

the Proxy class: 代理类:

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

the Contract class: 合同类:

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

Any ideas? 有任何想法吗?

Any program has only a single configuration file. 任何程序都只有一个配置文件。 In your case, that's the app.config of the Winforms program, which gets copied to programName.exe.config when the program is built. 在您的情况下,这就是Winforms程序的app.config,在构建程序时它将复制到programName.exe.config。

Any WCF configuration has to be in that file. 任何WCF配置都必须在该文件中。 The fact that your library has an app.config doesn't matter. 您的库具有app.config的事实并不重要。 You need to copy the relevant configuration entries from the library's app.config, and merge them with the app.config of the Winforms application. 您需要从库的app.config中复制相关的配置条目,并将它们与Winforms应用程序的app.config合并。

oo ...客户端app.config中没有客户端终结点信息的父元素。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 WCF 端点错误:找不到默认端点元素 - WCF Endpoint Error: Could not find default endpoint element 温莎WCF客户端-当配置中不存在时,“找不到默认端点元素” - Windsor WCF Client - “Could not find default endpoint element” when not present in config 找不到引用合同的默认端点元素 - 托管wcf - Could not find default endpoint element that references contract - Hosting wcf WCF错误 - 找不到引用合同的默认端点元素 - WCF Error - Could not find default endpoint element that references contract 使用WCF服务 - 找不到默认端点元素 - Consume WCF Service - Could not find default endpoint element 在WCF中找不到引用合同的默认终结点元素 - Could not find default endpoint element that references contract in WCF WCF运行时异常“找不到引用的默认终结点元素……” - WCF Runtime Exception “Could not find default endpoint element that references…” WCF 安装程序 class - 找不到引用合同的默认端点元素 - WCF installer class - Could not find default endpoint element that references contract WCF面临的问题:找不到默认端点 - Facing issue with WCF: Could not find default endpoint 找不到引用合同的默认终结点元素:通过Powershell cmdlet连接到WCF终结点 - Could not find default endpoint element that references contract :connect to WCF endpoint through Powershell cmdlet
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM