0
私のxamarinアンドロイドアプリでWCFサービスを呼び出そうとしていますが、メソッドを突然呼び出すときに、アプリケーションはホワイトアウトをすべて終了します。 私はこのtutorial from Xamarin we siteXamarin WCFコール
を使用し、ここに私のMainAxtivity.csファイルの内容です:あなたはすでにclient.GetDataAsync(2);
呼び出しの前にclient.GetDataCompleted
イベントをサブスクライブしようとすると、正しくWCFを設定すると仮定すると、
using Android.App;
using Android.Widget;
using Android.OS;
using System.Net;
using System.ServiceModel;
using System;
namespace TaskTracking.Droid
{
[Activity(Label = "TaskTracking.Droid", MainLauncher = true, Icon = "@drawable/icon")]
public class MainActivity : Activity
{
Button button1 = null;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.Main);
button1 = FindViewById<ButtonResource.Id.button1);
button1.Click += Button1_Click;
}
private void Button1_Click(object sender, System.EventArgs e)
{
try
{
EndpointAddress EndPoint = new EndpointAddress("http://10.10.2.162/TaskTracking.Service/TaskService.svc");
BasicHttpBinding binding = new BasicHttpBinding
{
Name = "basicHttpBinding",
MaxBufferSize = 2147483647,
MaxReceivedMessageSize = 2147483647
};
System.TimeSpan timeout = new System.TimeSpan(0, 0, 30);
binding.SendTimeout = timeout;
binding.OpenTimeout = timeout;
binding.ReceiveTimeout = timeout;
var client = new TaskServiceClient(binding, EndPoint);
client.GetDataAsync(2); /// Problem is here
client.GetDataCompleted += Client_GetDataCompleted;
}
catch (Exception ex) // Never catch anything
{
var message = ex.ToString();
}
}
private void Client_GetDataCompleted(object sender, GetDataCompletedEventArgs e)
{
var res = e.Result;
Toast.MakeText(this, res, ToastLength.Long);
}
}
}
について
詳細を次のように
Client_GetDataCompleted
コードを変更? – GeorgeChond@GeorgeChondはい、私はしましたが、それは動作しませんでした。 –