.net - 创建WCF Web服务实例时发生InvalidOperationException

标签 .net wcf web-services

我有一个从类库引用的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应用程序(正在调用您的类库)使用其自身配置文件中的数据,而不是库配置文件中的数据。

关于.net - 创建WCF Web服务实例时发生InvalidOperationException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24993/

相关文章:

.net - 通过SSL卸载应用程序网关连接到Azure托管的ElasticSearch终结点

c# - 序列化 Observable 集合时出错

java - 与 JAX-WS 2.2.x 一起使用的最低 JDK 和 JRE

java - 调用服务时将二进制值(字节数组)设置为 SOAP 元素

c# - c#中的最大容量集合

c# - InterruptedException (Java) 的 .NET 等价物是什么?

c# - SharpSVN - 无论如何都会收到待处理更新的通知吗?

javascript - 从 angularjs 调用 REST 服务时本地主机上的 CORS 问题

wcf - 在有故障的 WCF channel 上调用 Abort 会导致记录服务器端错误

java - 如何从 JAX-WS Web 服务中访问 ApplicationContext?