gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 13:36:00 24 4
gpt4 key购买 nike

我有一个从类库引用的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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com