我的代碼崩潰並在模擬器上出現以下錯誤。它嘗試運行GetDataFromOdataService()方法中的try塊,並引發錯誤併發出警報。我使用Xamarin.FormXamarin形式的OData連接
using Simple.OData.Client;
using System.Threading.Tasks;
private ODataClient mODataClient;
protected async override void OnAppearing()
{
base.OnAppearing();
await InitializeDataService();
await GetDataFromOdataService();
}
public async Task <bool> InitializeDataService(){
try {
mODataClient = new ODataClient ("http://services.odata.org/Northwind/Northwind.svc/");
}
catch {
await DisplayAlert("Error", "Connection Error", "OK", "Cancel");
System.Diagnostics.Debug.WriteLine("ERROR!");
}
return true;
}
public async Task<bool> GetDataFromOdataService(){
try {
myCustomers= await mODataClient.For("Customers").Top(10).FindEntriesAsync();
}
catch {
await DisplayAlert("Error", "Connection Error", "OK", "Cancel");
System.Diagnostics.Debug.WriteLine("ERROR!");
}
return true;
}
你能通過電子郵件發送你的最新代碼嗎? – Pete 2014-10-16 19:33:24
當然,我現在發送它。 – casillas 2014-10-16 19:33:41