WCF CLIENT APPLICATION CRASHES WHEN ACCESSING SERVICE

Hank Greenberg

Total Post:12

Points:84
Posted by  Hank Greenberg
 1150  View(s)
Ratings:
Rate this:
Hi Everyone,

I have created a wcf web service with access to ADO.net Entity Framework. Hosts on IIS and have console client. Everything works fine.. on my computer. When I send .exe file to another its just crashes and I cant figure out why. Code of console app:

MyServiceClient client = new MyServiceClient();
Console.WriteLine(client.GetOrders().First().Date_Accepted.ToString());
client.Close();
Console.ReadLine();

My web.config file is default with no changes except of connection string. Client app.config

<configuration>
<startup> 
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="BasicHttpBinding_IMyService" />
        </basicHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://93.77.254.167:9595/MyService.svc" binding="basicHttpBinding"
            bindingConfiguration="BasicHttpBinding_IMyService" contract="MyServiceReference.IMyService"
            name="BasicHttpBinding_IMyService" />
    </client>
</system.serviceModel>

Thanks in advance for any recommendations or solutions.
  1. Dev Patel

    Post:26

    Points:182
    Re: WCF client application crashes when accessing service

    Hi,


    Wrap you code in a try catch block and you will see what goes wrong.

    try
    {
     MyServiceClient client = new MyServiceClient();
     Console.WriteLine(client.GetOrders().First().Date_Accepted.ToString());
     client.Close();
     Console.ReadLine();
    }
    catch (Exception ex)
    {
     Console.WriteLine(ex);
    }

    I hope it helpful for you. 

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!