相关疑难解决方法(0)

在调试模式下运行的同一个 Android 应用程序在发布模式下崩溃

我使用 Xamarin for Visual Studio 和 C# 语言编写了一个简单的应用程序。代码是:

    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 …
Run Code Online (Sandbox Code Playgroud)

c# android signalr xamarin

1
推荐指数
1
解决办法
4969
查看次数

标签 统计

android ×1

c# ×1

signalr ×1

xamarin ×1