加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 资源网站 > 资源 > 正文

.net – 创建wcf Web服务实例时出现InvalidOperationException

发布时间:2020-12-14 18:49:11 所属栏目:资源 来源:网络整理
导读:我有一个从类库引用的WCF Web服务.在项目运行之后,当从类库中创建服务客户端对象时,我收到带有消息的InvalidOperationException: Could not find default endpoint element that references contract ‘MyServiceReference.IMyService’ in the ServiceMode
我有一个从类库引用的WCF Web服务.在项目运行之后,当从类库中创建服务客户端对象时,我收到带有消息的InvalidOperationException:

Could not find default endpoint element that references contract
‘MyServiceReference.IMyService’ in the ServiceModel client
configuration section. This might be because no configuration file was
found for your application,or because no endpoint element matching
this contract could be found in the client element.

我用来创建实例的代码是:

myServiceClient = new MyServiceClient();

MyServiceClient继承自的地方

System.ServiceModel.ClientBase

我该如何解决这个问题?

注意:我有一个单独的控制台应用程序,它只是创建相同的服务对象并调用它,它没有任何问题.

解决方法

Here is my app.config file of the class library:

您应该将此配置设置放到主应用程序的配置文件中. .NET应用程序(调用您的类库)使用来自它自己的配置文件的数据,而不是来自库配置文件.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读