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

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

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

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

PHP Fatal error: Call to undefined function bindtextdomain() in ……

PHP Fatal error: Call to undefined function bindtextdomain() in ……

问题: PHP网站上传后,一访问,提示: PHP Fatal error: Call to undefined function bindtextdomain() in …… 解决办法: 查php.ini文件, extension=php_gettext.dll 去掉前面...

IAR Error: Unknown or ambiguous symbol. main解决

IAR Error: Unknown or ambiguous symbol. main解决

网上下载了一个程序(含工程),打开一debug,提示:“Error (col 1): Unknown or ambiguous symbol. main”。经查:设置里没有生成debug information 解决办法: Project->C/C++Compiler-...

WinClone更新了

WinClone,Mac下备份Windows系统的好软件。可以克隆BootCamp分区安装的Windows,也可以将克隆文件安装到BootCamp分区。 之前已经写过一篇WinClone备份还原Windows的简易教程:http://www.xjtudll.cn/Exp/171/ 基本上来说,使用还...

Android Studio 错误: 非法字符: '\ufeff' 解决方案|错误: 需要class, interface或enum

Android Studio 错误: 非法字符: '\ufeff' 解决方案|错误: 需要class, interface或enum

Eclipse可以智能的把UTF-8+BOM文件转为普通的UTF-8文件,Android Studio还没有这个功能。 当将Eclipse工程转为Android Studio工程,并编译,就可能出现” 非法字符: '\ufeff' “之类的错误。 如下图: 如果遇到此种问题...

CC254x android6.x无法配对

参考资料: https://e2e.ti.com/support/wireless_connectivity/bluetooth_low_energy/f/538/t/457958 问题: 配对时提示密码或PIN错误,但是根本就没有到输入密码这一步,就直接说密码错误了。 环境: android 6....

C# 百分号格式化 保持原数不变

C# 百分号格式化 保持原数不变

C# 格式化数字 百分号 需求: 格式化数值为百分比 但是保持输入的数值不变 也就是不要C# 自带的格式化百分数 因为他会自动*100 再加上百分号 解决方案: % 外面套一层 ‘ ’Code var column = this.gridViewItemDet...

发表评论

访客

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