azure - 我现在应该如何使用带 PCL 或不带 PCL 的 Azure 移动服务?

标签 azure xamarin portable-class-library

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

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

如果我创建简单的 android lib 并从组件添加 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 支持方面存在一些问题。

有关在 PCL 中使用移动服务的分步指南,请参阅 this tutorial

如果您安装 Xamarin ComponentNuGet package为了将 Azure 移动服务添加到您的 Android 应用程序中,您会发现它添加了这些引用(以及其他引用):

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

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

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

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

关于azure - 我现在应该如何使用带 PCL 或不带 PCL 的 Azure 移动服务?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20226332/

相关文章:

azure - 是否可以从 Azure 工作线程进行打印?

Azure AD B2C - 使用 Azure AD 图形 API

Azure 私有(private) DNS 配置不适用于 P2S VPN

c# - 有没有办法检测用户是否按下接受或拒绝空投请求?

c# - CreateUserWithEmailAndPasswordAsync 错误 "Object reference not set to an instance of an object."

xaml - Xamarin.Forms:动画页面/布局过渡

xamarin.ios - Rx 2.1 和 Xamarin

c# - 带有可移植类库的 Soap Web 服务

c# - : MongoDB. Driver.MongoConnectionException:打开与服务器的连接时发生异常

mvvm - MVVM交叉行为和InvokeCommandAction