Platform: Xamarin Studio 4
Target Mobile: Android
I have an android app that calls a WCF service using basicHttpBinding that I have been working on using Xamarin Studio 4 that is running perfectly fine while in Debug Mode. To simplify things while troubleshooting this, I am calling a "Hello World" function of the WCF. No input parameters and only a string output.
In debug mode, I get the "Hello World" response. When I switch the application build to "Release", and run the application again, I get the following error message:
System.ServiceModel.EndpointNoFoundException: A system exception has occured. ---> System.Net.WebException: Error: ConnectFailure (No route to host) ---> System.Net.Sockets.SocketExcpetion: No route to host at System.Net.Sockets.Socket.Connect (System.Net.EndPoint remoteEP) [0x00000] in filename unknown: 0
BasicHttpBinding binding = CreateBasicHttp ();
BTSMobileWcfClient _client = new BTSMobileWcfClient (binding, endPoint);
_client.SayHelloCompleted += ClientOnSayHelloCompleted;
_client.SayHelloAsync();
private static BasicHttpBinding CreateBasicHttp()
{
BasicHttpBinding binding = new BasicHttpBinding
{
Name = "basicHttpBinding",
MaxBufferSize = 2147483647,
MaxReceivedMessageSize = 2147483647
};
TimeSpan timeout = new TimeSpan(0, 0, 30);
binding.SendTimeout = timeout;
binding.OpenTimeout = timeout;
binding.ReceiveTimeout = timeout;
return binding;
}
private void ClientOnSayHelloCompleted(object sender, SayHelloCompletedEventArgs sayHelloCompletedEventArgs)
{
string msg = null;
if (sayHelloCompletedEventArgs.Error != null)
{
msg = sayHelloCompletedEventArgs.Error.ToString();
}
else if (sayHelloCompletedEventArgs.Cancelled)
{
msg = "Request was cancelled.";
}
else
{
msg = sayHelloCompletedEventArgs.Result.ToString();
}
RunOnUiThread(() =>{
var lblSignInError = FindViewById<TextView> (Resource.Id.lblSignInError);
lblSignInError.Text = msg;
});
}
I`ve just run into the same problem in release compilation of my project. After awhile of wandering around I set internet permission on in ProjectOptions->AndroidApplication->Required permissions (in Xamarin studio). It looks working for me