2016-08-14 1 views
0

i a cette exceptionWCF CommunicationObjectFaultedException C#

Une exception non gérée du type 'System.ServiceModel.CommunicationObjectFaultedException' a eu lieu dans System.ServiceModel.dll

lorsque je tente ce code

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

sur app.config j'ai défini l'URL comme

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

i Serach sur ce problème et essayer d'ajouter cette URL sur cmd avec netsh mais pas le succès regard https://i.snag.gy/50tRok.jpg Que puis-je faire s'il vous plaît? thanks

Répondre

0

Il semble que votre objet ServiceHost soit éliminé juste après son ouverture, car host.Open() est asynchrone. Essayez ceci, par exemple:

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