c# - 无法从程序集 Simple.OData.Client.V3.Adapter 加载 OData 适配器

标签 c# xamarin odata

我有以下代码,希望从 Northwind 服务获取 oData (Simple.oData.Client)。一旦用户点击 Click 按钮,就会触发 oData 调用。它在控制台上打印出 before await 消息;但是,它不打印 after await 消息。这意味着 try-catch block 中的 await 操作有问题。我想知道如何处理这个问题。 我正在使用 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");
}

关于c# - 无法从程序集 Simple.OData.Client.V3.Adapter 加载 OData 适配器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29525268/

相关文章:

c# - 我可以在通用列表中使用 string.join

xaml - <Frame> Xamarin.Forms 上的特定于平台的 CornerRadius

macos - F# Interactive、NuGet 和外部库

c# - MonoTouch.Dialog 中的图像或视频附件字段

对 Sharepoint 2010 oData 的 Java HTTP 调用失败

c# - 模拟喷雾

c# - c# - 如何在c#中为字符串分配双倒(“)逗号?

c# - 任务栏右键单击应用程序上下文菜单[JumpList]

c# - OData 增量补丁安全

c# - RestSharp 和 OData - 反序列化 JSON 的问题