簡體   English   中英

WCF CommunicationObjectFaultedException C#

[英]Wcf CommunicationObjectFaultedException c#

我有這個例外

System.ServiceModel.dll中發生了類型為'System.ServiceModel.CommunicationObjectFaultedException'的未處理異常

當我嘗試此代碼

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

在app.config上,我像

   <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我該怎么辦? 謝謝

看起來您的ServiceHost對象在打開后就被釋放了,因為host.Open()是異步的。 試試這個,例如:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM