我有以下代码,我希望从Northwind服务获得oData(Simple.oData.Client).一旦用户点击Click按钮,它就会触发oData Call.它在控制台上等待消息之前打印出来;但是,在等待消息后它不会打印.这意味着try-catch块中的等待操作有些不对劲.我想知道如何处理这个问题.
我正在使用Xamarin.iOS平台.
async partial void Click_TouchUpInside (UIButton sender)
{
var client= new ODataClient("http://services.odata.org/Northwind/Northwind.svc/");
Console.WriteLine("before await");
try {
var packages = await client
.For("Customers").
FindEntriesAsync();
}
catch(AggregateException e) {
Console.WriteLine(e);
Console.WriteLine(e.InnerException);
}
Console.WriteLine("after await");
}
这是详细错误消息:
System.AggregateException: One or more errors occurred —>
System.AggregateException: One or more errors occurred —>
System.InvalidOperationException: Unable to load OData adapter from
assembly Simple.OData.Client.V3.Adapter —>
System.IO.FileNotFoundException: Could not load file or assembly
‘Simple.OData.Client.V3.Adapter’ or one of its dependencies. The
system cannot find the file specified.
解决方法:
需要知道如何解决此问题的人,以下是Simple.OData.Client github的源代码所有者的详细说明.
https://github.com/object/Simple.OData.Client/issues/53
我在Main.cs中添加了一行代码Simple.OData.Client.V3Adapter.Reference(),它就像一个魅力.
static void Main (string[] args)
{
Simple.OData.Client.V3Adapter.Reference();
UIApplication.Main (args, null, "AppDelegate");
}