Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How should i use Azure Mobile Services with PCL or without it now?

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

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.

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

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

on

 public static MobileServiceClient MobileService = new MobileServiceClient(
    "https://no-link-here.azure-mobile.net/",
    "no-key-here");    
like image 309
xakpc Avatar asked Nov 26 '13 19:11

xakpc


People also ask

What is the main purpose of using the Azure Mobile App?

Use the Mobile Apps feature of Azure App Service to rapidly build engaging cross-platform and native apps for iOS, Android, Windows or Mac; store app data in the cloud or on-premises; authenticate customers; send push notifications; or add your custom back-end logic in C# or Node. js.

What are three uses for the Azure Mobile App?

Application developmentSimplify and accelerate development and testing (dev/test) across any platform. Build secure apps on a trusted platform. Embed security in your developer workflow and foster collaboration with a DevSecOps framework.

Which Azure service can be used to deploy mobile app?

Azure App Service lets you create apps faster with a one-of-a kind cloud service to quickly and easily create enterprise-ready web and mobile apps for any platform or device and deploy them on a scalable and reliable cloud infrastructure.


2 Answers

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.

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

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

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).

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.

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.

like image 123
Paul Batum Avatar answered Sep 27 '22 18:09

Paul Batum


Make sure you have called

CurrentPlatform.Init(); 

before instantiating the mobile service client

like image 30
Magnus Ahlin Avatar answered Sep 27 '22 19:09

Magnus Ahlin