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

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

xjtudll4年前 (2021-08-23)技术心得2050

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

QQ for Mac老提示密码错误

这段时间,一直在折腾黑苹果,好不容易将黑苹果装的差不多了,下了个QQ for Mac,安装什么的都很顺利,但是就是死活登陆不上。 1、检查过大小写,确认过密码,没错。在Windows下可以使用;在Mac系统中,Web QQ也可使用。 2、采用复制粘贴的方法将密码粘贴到密码框,依旧提示密码错误。...

水晶报表的文本对象中怎么插入换行符

水晶报表的文本对象中如何插入换行符?我的文本对象要显示的值是从RichTextBox中读出来的,但文本对象不能显示“\n”,怎么让文本对象换行呢?------解决方案--------------------1:不要用文本对象,用公式2:把\n替换成水晶报表里的换行符号Replace(字段,'...

eclipse显示行号及字体设置

eclipse显示行号及字体设置

1 编辑器显示行号 Windows -> Preferences -> General -> Editors -> Text Editors -> Show line numbers(勾选) 2 显示字体设置 Windows -> Preferences -&g...

Altium连续选择多个元件

Altium连续选择多个元件

以前在Protel99SE中,选中一个元件后,只要不取消选择(deselect),还可以接着选择元件,一直到足够为止。而Altium默认设置中,选择元件后,若你单击了PCB其他区域,之前的选择将失效,只能通过 Shift+鼠标单击来完成多个元件的选择。这种做法使得从Protel99SE转过来的用户极...

win7怎样彻底删除打印机驱动

win7怎样彻底删除打印机驱动

https://zhidao.baidu.com/question/1802002455667765027.html 1、开始---设备和打印机:随便选择一个打印机图标,选择打印机服务器属性; 2、单击打印服务器属性---驱动程序---删除,选择删除驱动程序和驱动程序包,点确定; 3、无法删除...

Can't place multiple pins assigned to pin location Pin_101

Can't place multiple pins assigned to pin location Pin_101

错误:Error (176310): Can't place multiple pins assigned to pin location Pin_101 (IOPAD_X34_Y18_N21)     Info (176311): Pin addr[8] is as...

发表评论

访客

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