Home > DeveloperSection > Forums > WCF client application crashes when accessing service
Hank Greenberg
Hank Greenberg

Total Post:12

Points:84
Posted on    June-19-2013 3:26 AM

 ADO.Net ADO.Net 
Ratings:


 1 Reply(s)
 786  View(s)
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.


Dev Patel

Total Post:26

Points:182
Posted on    June-19-2013 8:28 AM

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. 

Don't want to miss updates? Please click the below button!

Follow MindStick