I've written a simple app using Xamarin for Visual Studio and C# language. The code is:
HubConnection hubConnection;
IHubProxy chatHubProxy;
async void btnConnect_Click(object sender, EventArgs e)
{
try
{
TextView log = FindViewById<TextView>(Resource.Id.txtLog);
base.OnResume();
hubConnection = new HubConnection("http://192.168.1.3:2010/signalr");
chatHubProxy = hubConnection.CreateHubProxy("MyHub");
chatHubProxy.On<string>("AddMessage", (message) =>
{
TextView text = FindViewById<TextView>(Resource.Id.txtLog);
text.Text = message;
});
var localIP = "192.168.1.104"; //the android device has this IP
await hubConnection.Start();
var srvrMessage = chatHubProxy.Invoke<string>("LoginFromMobile", "mahdi", "p@SsW0Rd",
hubConnection.ConnectionId, localIP);
if (srvrMessage != null)
{
log.Text = srvrMessage.Result;
}
else
log.Text = "can't connect to server";
}
catch (Exception ex)
{
TextView text = FindViewById<TextView>(Resource.Id.txtLog);
text.Text = ex.StackTrace;
}
}
When I click the "Connect" button, I get connected to a SignalR Hub located on my pc in the network, and everything works fine in DEBUG mode. But unfortunately, when I compile the same app in RELEASE mode, I get the following error:
I can't see why... Please tell me what I need to consider to make the app work right in Release mode too. Is there any permission problem? Some config or setting missing? Your guides are truly helpful and appreciated.