为什么< system.serviceModel> app.config中缺少部分? [英] Why is the <system.serviceModel> section missing from app.config?

查看:115
本文介绍了为什么< system.serviceModel> app.config中缺少部分?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用WCF服务.我添加了服务参考,现在我要调用它:

I'm trying to consume a WCF service. I added a Service Reference, and now I'm trying to call it:

BusStopServiceBinding.BusStopPortTypeClient client = new BusStopServiceBinding.BusStopPortTypeClient();

但是,我遇到此错误:

找不到引用合同的默认端点元素 ServiceModel客户端中的"BusStopServiceBinding.BusStopPortType" 配置部分.这可能是因为没有配置文件 为您的应用程序找到,或者因为没有匹配的终结点元素 可以在client元素中找到该合同.

Could not find default endpoint element that references contract 'BusStopServiceBinding.BusStopPortType' 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 contract could be found in the client element.

我的app.config文件如下所示:

<?xml version="1.0"?>
<configuration>
<configSections>
</configSections>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup>
</configuration>

如您所见,

没有serviceModel部分.我应该手动添加它吗?如果要添加,应该放入什么?

No serviceModel section, as you can see. Should I add it manually, and if so, what should I put in it?

推荐答案

本节适用于WCF配置.在Visual Studio的工具"部分中,您有一个"WCF服务配置编辑器",可帮助您创建此部分.如果没有此部分,则必须在代码中对其进行配置,但这不是最佳实践. 在这一部分中,您必须放置端点,安全设置,绑定,wcf合同,...

This section is for WCF configuration. In the Tools section in visual studio you have a "WCF Service configuration editor" which help you to create this section. If you don't have this section you must configure it in code, but it is not the best practise. In this section you have to put the end point, the security settings, bindings, the wcf contract,...

这篇关于为什么&lt; system.serviceModel&gt; app.config中缺少部分?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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