【发布时间】:2014-10-17 04:57:22
【问题描述】:
我的代码崩溃并在模拟器上出现以下错误。它尝试在 GetDataFromOdataService() 方法中运行 try 块并抛出错误并发出警报。我正在使用 Xamarin.Form
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;
}
【问题讨论】:
-
您可以通过电子邮件发送您的最新代码吗?
-
好的,我现在发送。
标签: xamarin odata xamarin.forms