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

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

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

环境: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 客户端配置部分中,找不到引用协定” 的相关文章

windows server 2008R2 初始密码策略:老提示密码不符合策略

参考资料: http://zhidao.baidu.com/link?url=52XEZ-w-pIcmk2S-UkB8V1b9NOHJm3kBPECZHwD6WhT7DxofLXu03UsCFN_DqEJ4KJ6UtlL-b7a4c-yNarXfCa 问题: windows...

IAR如何生成Hex文件

IAR如何生成Hex文件

MSP430在用JTAG下载的时候,Hex文件是用不上的。但是如果用Proteus仿真的话(只有Proteus 7.6及其以上版本才支持MSP430仿真),只支持Hex文件仿真,所以有必要输出Hex文件。 打开IAR的工程选项,选中左边栏的Linker,如图所示。 勾中【Output file】...

Keil MDK 查看局部变量提示<not in scope>

Keil MDK 查看局部变量提示

现象: 在进行STM32开发的时候出现了,调试代码,添加变量Watch时,显示not in scope。 处理方式: 因为代码开了优化的处理,把优化改到Level0,就可以解决问题。...

Altium避开某些区域覆铜

Altium避开某些区域覆铜

覆铜的时候,有时候会有些地方不能覆铜。例如下图,如果想在A区域覆铜,而B区域不覆铜。该怎么办呢?? 网上有云: 1、B画keepout层,然后再覆铜,这样B就可避开覆铜。 2、B区域放置一个同等大小焊盘,然后覆铜。 以上方法均不怎么完美,重新覆铜的画有可能会影响覆铜的形状。 其实Altium已经自...

PowerPCB5.01安装

PowerPCB5.01安装

软件下载地址:http://www.mcu123.com/news/Soft/embsof/pcb/200609/104.html我目前就是用的这个,暂时没发现什么问题。1、安装时选择“Node-locked with FLEXid Key(teal)”  ...

穆斯林祈祷时间定义

穆斯林每天祈祷五次,时间有规定,需要在一个特定的时间段。五次祈祷分别是:晨礼、晌礼、晡(bū)礼、昏礼和宵礼。如下表所示: 名 称...

发表评论

访客

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