我现在应该如何使用带有 PCL 或不带 PCL 的 Azure 移动服务? [英] How should i use Azure Mobile Services with PCL or without it now?

查看:13
本文介绍了我现在应该如何使用带有 PCL 或不带 PCL 的 Azure 移动服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我更新到最新版本的 Xamarin,其中完全支持"PCL.我现在如何使用 Azure 移动服务?

I updated to latest version of Xamarin, where PCL is "fully supported". How can i use Azure Mobile Services now?

如果我创建 PCL 库并尝试使用 NuGet 添加它,则无法安装Newtonsoft.Json 5.0.8",因为它需要缺少portable-net45+wp80+MonoAndroid10+MonoTouch10".

if i create PCL lib and trying to add it with NuGet it failed to install "Newtonsoft.Json 5.0.8" because it needs "portable-net45+wp80+MonoAndroid10+MonoTouch10" which is missing.

如果我创建简单的 android 库并从组件中添加 Azure,它会生成异常:

if i create simple android lib and add Azure from components it's generate excepton:

System.InvalidOperationException:Windows Azure 移动服务未找到当前平台的程序集.确保当前...

System.InvalidOperationException: A Windows Azure Mobile Services assembly for the current platform was not found. Ensure that the cur…

 public static MobileServiceClient MobileService = new MobileServiceClient(
    "https://no-link-here.azure-mobile.net/",
    "no-key-here");    

推荐答案

首先,请确保您使用的是 NuGet 或 Xamarin 组件的 1.1.5 或更高版本,因为以前的版本在 PCL 支持方面存在一些问题.

First, make sure you are using version 1.1.5 or above of either the NuGet or the Xamarin Component as previous versions had some issues with PCL support.

有关在 PCL 中使用移动服务的分步指南,请参阅本教程.

For a step by step guide on using Mobile Services in a PCL, see this tutorial.

如果您安装了 Xamarin 组件NuGet 包 Azure 移动服务到您的 Android 应用程序中,您会发现它添加了以下引用(以及其他):

If you install the Xamarin Component or the NuGet package for Azure Mobile Services into your Android application, you will find it adds these references (among others):

  • Microsoft.WindowsAzure.Mobile.dll
  • Microsoft.WindowsAzure.Mobile.Ext.dll

第一个程序集是 PCL,第二个程序集具有特定于平台的实现(这就是上面错误消息所缺少的).

The first assembly is a PCL, the second assembly has platform specific implementation (and that is what you are missing with the error message above).

用于移动服务的 NuGet 包具有为 Xamarin.iOS 和 Xamarin.Android 定义的特定平台目标,因此如果您使用的是 Visual Studio,则可以选择仅使用 NuGet 并完全跳过 Xamarin 组件.

The NuGet package for Mobile Services has specific platform targets defined for Xamarin.iOS and Xamarin.Android so if you are using Visual Studio, you have the option to use just the NuGet and skip the Xamarin component completely.

由于 BCL NuGet 包(HttpClient、Bcl.Build 等)与 Xamarin 交互的方式存在一些错误,您需要注意一些解决方法.有关必要步骤,请参阅上面的教程.

Due to some bugs in how the BCL NuGet packages (HttpClient, Bcl.Build, etc) interact with Xamarin, there are a few workarounds you'll need to be aware of. See the tutorial above for the necessary steps.

这篇关于我现在应该如何使用带有 PCL 或不带 PCL 的 Azure 移动服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆