我已經爲Visual Studio和C#語言編寫了一個使用Xamarin的簡單應用程序。該代碼是:在調試模式下運行的相同Android應用程序,在發佈模式下崩潰
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", "[email protected]",
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;
}
}
當我點擊「連接」按鈕,我得到連接到位於我的網絡PC上SignalR中心,一切工作正常在調試模式。但不幸的是,當我complite在釋放模式相同的應用程序,我得到以下錯誤:
我不明白爲什麼?請告訴我,我需要考慮,以使應用程序工作在發佈模式也是如此。有沒有許可問題?一些配置或設置丟失? 您的導遊非常樂於助人。
你解決這個問題?我有同樣的問題。另外,我注意到在服務器上有一些字典有錯誤。所以我認爲它在發佈模式下的請求有所不同 –
System.ArgumentNullException:值不能爲空。 參數名稱:密鑰 在System.Collections.Generic.Dictionary'2.FindEntry(TKey鍵) 在Microsoft.AspNet.SignalR.Hubs.HubDispatcher.AuthorizeRequest(IRequest請求) –