【问题标题】:Wcf CommunicationObjectFaultedException c#Wcf CommunicationObjectFaultedException c#
【发布时间】:2016-12-20 19:29:47
【问题描述】:

我遇到了这个异常

未处理的类型异常 'System.ServiceModel.CommunicationObjectFaultedException' 发生在 System.ServiceModel.dll

当我尝试这段代码时

        using (ServiceHost host = new ServiceHost(typeof(WcfProductService)))
        {
            host.Open();
            Console.WriteLine("server is open");
        }

在 app.config 上我定义了类似的 url

   <endpoint address="http://localhost:9999/ProductSercie" binding="basicHttpBinding"
        bindingConfiguration="" contract="IWcfProductService.IWcfProductService"
        name="ProductServiceEndPoint" kind="" endpointConfiguration="" />

我在这个问题上搜索并尝试使用 netsh 在 cmd 上添加这个 url 但没有成功 看https://i.snag.gy/50tRok.jpg 请问我该怎么办? 谢谢

【问题讨论】:

    标签: c# wcf app-config


    【解决方案1】:

    看起来你的 ServiceHost 对象在你打开它之后就被释放了,因为 host.Open() 是异步的。 试试这个,例如:

        using (ServiceHost host = new ServiceHost(typeof(WcfProductService)))
        {
            host.Open();
            Console.WriteLine("server is open");
            Console.ReadLine();
        }
    

    【讨论】:

      猜你喜欢
      • 2013-01-04
      • 2010-11-17
      • 2010-11-15
      • 2021-12-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多