在ServiceModel客户端配置部分中找不到名称为'和合同为'I'的终结点元素. [英] Could not find endpoint element with name ' and contract 'I' in the ServiceModel client configuration section.

查看:585
本文介绍了在ServiceModel客户端配置部分中找不到名称为'和合同为'I'的终结点元素.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理基本WCF服务-客户端WCF服务-消费者基本Wcf服务模型,如下所示:

I am working on a Base WCF Service- Client WCF service - Consumer Base Wcf servcie model as following:

在此模型中,我创建了一个基本WCF服务并创建了1个WCF服务,即; ClientWCFService和1个ASMX服务,即;使用BaseWCFServiceProxy.cs的ClientASMXservice,使用SVCUtil.exe的Base WCF服务的Proxy类.

In this model, I have created a Base WCF service and created 1 WCF service i.e; ClientWCFService and 1 ASMX service i.e; ClientASMXservice using the BaseWCFServiceProxy.cs the Proxy class of Base WCF Service using SVCUtil.exe.

ClientWCFService和ClientASMXservice在StandAlone环境中可以正常工作. 现在,我使用相同的代理类BaseWCFServiceProxy.cs创建了一个消费者控制台应用程序,以使用BaseWcfService类访问ClientWCFService和ClientASMXservice.

The ClientWCFService and ClientASMXservice are working fine in StandAlone environment. Now, I created a Consumer Console Application using the same proxy class BaseWCFServiceProxy.cs to access both of the ClientWCFService and ClientASMXservice using the BaseWcfService class.

根据 OOP规则,BaseWcfService类是ClientWCFService和ClientASMXservice的基类,我可以使用Base服务类构造函数访问这些服务.

As per the OOP rules, BaseWcfService class is the base class for the ClientWCFService and ClientASMXservice and i can access these Services using the Base service class constructor.

服务电话如下: 用于ClientWCFService

The service calls are as following: for ClientWCFService

 ModelWcfServiceContractClient _client = new ModelWcfServiceContractClient("IModelWcfServiceContract","http://localhost:64242/ClientWCFServiceWcfUsingSVCProxy.svc");

用于ClientASMXservice

for ClientASMXservice

ModelWcfServiceContractClient _client = new ModelWcfServiceContractClient("IModelWcfServiceContract","http://localhost:64396/ClientASMXServiceWcfUsingSVCProxy.asmx");

Consumer Console应用程序运行良好,但在运行时初始化ModelWCFServiceContractClient对象, 会抛出 InvalidOperation异常:

The Consumer Console application is building fine, but at run time while initializing the ModelWCFServiceContractClient object, it throws the InvalidOperation Exception as :

找不到名称为'IModelWcfServiceContract'的终结点元素 和在ServiceModel客户端中签约'IModelWcfServiceContract' 配置部分.这可能是因为没有配置文件 为您的应用程序找到,或者因为没有匹配的终结点元素 该名称可以在client元素中找到.

Could not find endpoint element with name 'IModelWcfServiceContract' and contract 'IModelWcfServiceContract' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this name could be found in the client element.

我尝试为每种类型的服务使用不同的终结点来解决此问题,但无法成功.

I have tried using different endpoints for every type of service to resolve this issue but could not get success.

可以更快地做出响应.另外,请不要仅仅通过清除拼写错误来帮助我,因为这将浪费我的时间来阅读由于清除拼写错误而生成的警报.时间对我来说至关重要.

A faster response would be Appreciated. Also please don't help me by just clearing spelling mistakes because it will waste my time to read the Alert that would be generated due to the clearing spell mistakes. Time is critical for me..

谢谢

推荐答案

尝试一下(希望您可以照做):

Try this (hopefully you can follow):

在Visual Studio中,选择包含ModelWcfProxy的ServiceReference(生成ModelWcfServiceContractClient代理类的项目)的项目.

In Visual Studio, Select the project that contains the ServiceReference for your ModelWcfProxy (the one that generated the ModelWcfServiceContractClient proxy class).

从解决方案资源管理器菜单栏中选择显示所有文件".

Choose, "Show all files" from the Solution Explorer menu bar.

展开服务参考"文件夹和生成的服务参考".找到.svcmap文件,在下面查找以找到Reference.cs文件.

Expand the Service References folder and the generated Service Reference. Find the .svcmap file, look underneath to find the Reference.cs file.

在生成的界面顶部,应定义一个System.ServiceModel.ServiceContractAttribute.在属性构造函数中,您应该看到正在设置的ConfigurationName属性.此合同配置名称应与config中定义的名称或要发送到方法中的名称匹配:

On the top of your generated interface there should be a System.ServiceModel.ServiceContractAttribute defined. In the attribute constructor, you should see a ConfigurationName property being set. This contract configuration name should match the name defined in config or that you are sending in to your method:

ModelWcfServiceContractClient _client = new ModelWcfServiceContractClient("IModelWcfServiceContract","http://localhost:64242/ClientWCFServiceWcfUsingSVCProxy.svc");

希望这会有所帮助.

这篇关于在ServiceModel客户端配置部分中找不到名称为'和合同为'I'的终结点元素.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆