当前位置:首页 > 技术心得 > 正文内容

WCF:在 ServiceModel 客户端配置部分中,找不到引用协定

xjtudll5年前 (2021-08-23)技术心得6430

环境:VS2010 + C#(DLL) + WCF

即我使用C#编写了一个DLL,在DLL里面远程调用WCF服务,然后EXE程序在调用DLL里面的接口时,出现了如下错误:

System.InvalidOperationException: 在 ServiceModel 客户端配置部分中,找不到引用协定“ServiceReference1.IPathIdentifyService”的默认终结点元素。这可能是因为未找到应用程序的配置文件,或者是因为客户端元素中找不到与此协定匹配的终结点元素。

   在 System.ServiceModel.Description.ConfigLoader.LoadChannelBehaviors(ServiceEndpoint serviceEndpoint, String configurationName)

   在 System.ServiceModel.ChannelFactory.ApplyConfiguration(String configurationName, Configuration configuration)

   在 System.ServiceModel.ChannelFactory.ApplyConfiguration(String configurationName)

   在 System.ServiceModel.ChannelFactory.InitializeEndpoint(String configurationName, EndpointAddress address)

   在 System.ServiceModel.ChannelFactory`1..ctor(String endpointConfigurationName, EndpointAddress remoteAddress)

   在 System.ServiceModel.EndpointTrait`1.CreateSimplexFactory()

   在 System.ServiceModel.EndpointTrait`1.CreateChannelFactory()

   在 System.ServiceModel.ClientBase`1.CreateChannelFactoryRef(EndpointTrait`1 endpointTrait)

   在 System.ServiceModel.ClientBase`1.InitializeChannelFactoryRef()

   在 System.ServiceModel.ClientBase`1..ctor()

...

解决方法:

调用WCF的类库(即xxx.dll)会有一个app.config文件,把这个文件中的以下部分

<system.serviceModel>

省略

</system.serviceModel>

复制粘贴到主程序(EXE所在工程)的app.config文件中的<configuration></configuration>中。

扫描二维码推送至手机访问。

版权声明:本文由鸟的天空发布,如需转载请注明出处。

本文链接:http://www.xjtudll.cn/Exp/613/

标签: WCF
分享给朋友:

“WCF:在 ServiceModel 客户端配置部分中,找不到引用协定” 的相关文章

浅谈单片机程序设计中的“分层思想”

    网络转载,出处未知,收藏甚久。     分层的思想,并不是什么神秘的东西,事实上很多做项目的工程师本身自己也会在用。看了不少帖子都发现没有提及这个东西,然而分层结构确是很有用的东西,参透后会有一种恍然大悟的感觉。如果说我不懂LCD...

ListView.setOnItemClickListener 点击无效

如果ListView中的单个Item的view中存在checkbox,button等view,会导致ListView.setOnItemClickListener无效, 事件会被子View捕获到,ListView无法捕获处理该事件. 解决方法: 在checkbox、button对应的view处加...

c# textbox的passwordchar清空

//三种都是清空 this.textBox1.PasswordChar = new char(); this.textBox1.PasswordChar = '\0'; this.textBox1.PasswordChar = default(char);...

Quartus II Warning: Found 6 node(s) in clock paths which may be acting as ripple and/or gated clocks

Quartus II编译某代码之后,老是提示如下warning: Warning: Found 6 node(s) in clock paths which may be acting as ripple and/or gated clocks -- node(s) analyzed as buf...

浅析电波表——基本工作原理

浅析电波表——基本工作原理

一、电波表简介 电波钟表,也称为无线控制计时钟表 ( 英文名称为:Radio Controlled Timepieces)。电波钟是一种新兴的计时产品。目的是为了世界时间同步统一。主要是为了解决目前石英钟表的精确度问题。石英钟表较机械钟表已准确很多,但日差仍有一秒半秒。这种误差对于人们的日常生活没有...

CC2541功耗测试结果

CC2541功耗测试结果

测试环境: 1、CC2541开发板 2、使用heartrate工程,修改心率发送间隔时间为1秒(原来是2秒) 测试结果: 慢速广播 10 uA 快速广播 2 mA 仅定时器运行:1.2 uA(蓝牙关闭) 休眠:0.34 uA 与手机连接时刻:1 mA 约持续10秒 保持连接状态(1秒发送一次心率值...

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。