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

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

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

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

Virtual Box Android X86安装:please check you have enough free disk space to install androd x86

原因:下载的iso有问题,换一个iso吧。 当然,前提是你分配的空间确实是足够的,默认8GB肯定是足够的。 我分配了8GB空间,在写入的时候,却提示: Installation failed:please check you have enough free disk space to...

Xcode5 Version与Build设置

Xcode5 Version与Build设置

在ios中,有两种version,一种是 CFBundleVersion ("Bundle Version"),也就是我们看到的Version,另一种是CFBundleShortVersionString ("Bundle version string, short&q...

Xcode5如何添加或更换图标

Xcode5如何添加或更换图标

参考文献: 官方教程:https://developer.apple.com/library/ios/qa/qa1686/_index.html 1、添加图标图片资源到工程 2、选择对应的App Icons。如果从来没有添加过,【Resource】处可以自己选择想要的图标资源。选择好后编译即可。编...

老单单据上下查,某些字段在上下查出来的界面看不到

https://vip.kingdee.com/questions/55600564193023233/answers/55600565182629120 问题描述: 例如:将外购入库上的【保管】字段显示在序时簿界面,但是在采购发票序时簿上查外购入库单的界面看不到【保管】,查询起来不方便。 解决方案...

金蝶K3:api说明打开只有网页的头,没有内容

金蝶K3:api说明打开只有网页的头,没有内容

问题描述 api说明打开只有网页的头,没有内容。问题的图片如下: 问题原因 检查api日志可以看到如下内容:数据库访问异常,请联系管理员... 解决方案 打开账套管理--点击异常账套--点击左上角的属性,检查配置的身份是不是SQL server身份认证,是不是没有填写sa的密码。...

Xcode ios模拟器下载及安装教程

Xcode ios模拟器下载及安装教程

1 通过Xcode下载 最新版的Xcode安装后,通常只带最新ios系统的模拟器。例如,Xcode 5.01就只带了ios7.03的模拟器。通过Xcode可以下载早期版本的模拟器。 Xcode->Preferences->Downloads Downloads下的Components就...

发表评论

访客

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