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

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

xjtudll3年前 (2021-08-23)技术心得620

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

eclipse菜单里找不到“Android SDK Manager”

eclipse菜单里找不到“Android SDK Manager”

有的时候ADT即使安装正确了,却找不到Android SDK Manager。 Windows选项卡里没有Android SDK Manager,也没有Android Virtual Device Manager。如下图所示。 解决办法如下: 1、Windows选项卡,Customize Pers...

冰点文库 老是停止工作

冰点文库 老是停止工作

问题: 每次使用时,都提示停止工作   原因: Adobe Flash Player的更新出现了问题,请重新下载并安装最新版的Adobe Flash Player 冰点文库下载器的工作原理,使得它必须借助Adobe Flash Player实现PDF文件的转换。...

未能加载文件或程序集“file:///C:\Program Files (x86)\SAP BusinessObjects\Crystal Reports

首先我使用工具的信息为:Visual Studio 2010 ,水晶报表的版本为:13.0.0.99。 我想做的就是:使用VS2010中的WPF,将DataSet中的数据展示出来。(DataSet中的数据来自Oracle数据库) 但是我在运行的时候出现了这个问题: 未能加载文件或程序集“...

Mac OS安装心得

配置我就不说了,我的是Acer 4738G 安装的系统:东皇V3.2 下载地址:http://www.verycd.com/topics/2887773/ 具体安装教程可参照: 《新手windows下安装苹果教程。最详细,最全面,最值得看的教程》http://bbs.pcbeta.com/v...

ESD及静电的特点

什么是ESD ESD是代表英文Electrostatic Discharge[1] 即“静电放电”的意思。ESD是本世纪中期以来形成的以研究静电的产生与衰减、静电放电模型、静电放电效应如电流热(火花)效应(如静电引起的着火与爆炸)和电磁效应(如电磁干扰)等的学科。近年来随着科学技术的飞速发展、微电...

File.Create创建文件后,需要释放

重点就是要close if (!File.Exists(SavePath))             {       ...

发表评论

访客

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