Getting the following error in my MainActivity.cs in my Android project of a Xamarin.Forms solution:
CurrentPlatform is inacessbile due to its protection level
From the following line of code which is inside the OnCreate(), with only the CurrentPlaftorm portion underlined:
Microsoft.WindowsAzure.MobileServices.CurrentPlatform.Init();
I didn't receive this error until I upgraded my MonoAndroid to v7.0 from v6.0 and did all the necessary updates that come with that like JDK 1.8.
Wondering if someone can explain what this error means and why it is being invoke specifically for the CurrentPlatform.
I tried to recreate this error in a new project but once I typed Microsoft.WindowsAzure.MobileServices. it had the CurrentPlatform option available with no issue.
Also now a line using the MobileServiceClient type calling the LoginAsync() from the WindowsAzure component throws two errors on the parameters which used to be:
await client.LoginAsync(context, "facebook");
But I receive the following two errors now:
Argument 1: cannot convert from 'Android.Content.Context' to 'Microsoft.WindowsAzure.MobileServices.MobileServiceAuthenticationProvider'
Argument 2: cannot convert from 'string' to 'Newtonsoft.Json.Linq.JObject'
Not sure why these two areas of code broke when I changed my Android Target SDK as they were just part of the Microsoft.WindowsAzure components.
Not sure why these two areas of code broke when I changed my Android Target SDK as they were just part of the Microsoft.WindowsAzure components.
According to your description, I assumed that it dues to the version of Azure Mobile Client SDK you referenced.
For Azure Mobile Client SDK 3.1.0, you client would reference the lib from the following path:
Microsoft.Azure.Mobile.Client.3.1.0\lib\monoandroid\Microsoft.WindowsAzure.Mobile.Ext.dll
You could leverage ILSpy to check the extension methods for LoginAsync as follows:
While for Azure Mobile Client SDK 4.0.0-alpha-001, if your MonoAndroid >= 4.4, then the lib would be reference under:
Microsoft.Azure.Mobile.Client.4.0.0-alpha-001\lib\monoandroid44\Microsoft.Azure.Mobile.Client.dll
For Azure Mobile Client SDK 4.0.0, if your MonoAndroid >= 7.1, then the lib would be reference under:
Microsoft.Azure.Mobile.Client\4.0.0\lib\monoandroid71\Microsoft.Azure.Mobile.Client.dll
My previous project targets on Android 6.0, then the lib would only reference Microsoft.Azure.Mobile.Client.4.0.0\lib\netstandard1.4\Microsoft.Azure.Mobile.Client.dll, and there has no extension methods for LoginAsync via server-flow authentication.
In summary, from your code await client.LoginAsync(context, "facebook");, you are using Server-managed authentication, I would recommend that you could use Azure Mobile Client SDK 3.1.0 without upgrading your Android SDK version or use the latest Azure Mobile Client SDK 4.0.0 and upgrading your Android SDK version to 7.1 or higher.
Additionally, the code client.LoginAsync(MobileServiceAuthenticationProvider.Facebook,{JObject token}) is using Client-managed authentication, at this point, your app can independently contact the identity provider and then provide the returned token during login with your azure mobile backend.
Related
I'm trying to implement Azure Mobile Services in my Xamarin.Forms app.
I'm following this link and it works on iOS but not on Android.
It throws this exception:
MobileServiceInvalidOperationException - "The server did not provide a response with the expected content."
I have tried switching between HTTP and HTTPS but could not get it working.
It works on Android (native) as well, just not on Xamarin.Android
Any help?
Your issue is tracked here, and seems to be because of the following:
we don't support .Net Core 2.1 in the SDK today. Unfortunately, we don't have a workaround today and like Ela said, the we don't have an ETA for a new release or other SDK to use for .Net Core 2.1 compatibility yet, so your only workaround is to stick with .Net Core 2.0 for now.
There seems to be a temporary work around here, by brendanzagaeski to in the call to new MobileServiceClient():
Either pass in an HttpClientHandler instance
Or pass in an instance of AndroidClientHandler
It seems like AndroidClientHandler is the one that works the most often.
Check if "microsoft.azure.mobile.client" is referenced on your project. If not, try installing a lower version of the "microsoft.azure.mobile.client" through nuget package on your project add the using directive and then update the "microsoft.azure.mobile.client" through nuget package.
And update any pending package.
I am developing a Xamarin.Forms PCL mobile application and need access to an internal API that requires authentication via Azure. My coworker gave me a code snippet that works in a console application, and I am attempting to adapt it for my mobile application.
I am able to successfully add the ADAL package to the PCL. However, authentication requires that I pass along a set of PlatformParameters for each platform-specific version. When I attempt to add the ADAL package to the Xamarin.Android project, I get the following errors in my Resource.Designer.cs file:
ERROR: 'Resource.Id' does not contain a definition for 'agentWebView'
ERROR: 'Resource.Layout' does not contain a definition for 'WebAuthenticationBroker'
The relevant (auto-generated) lines of code in Resource.Designer.cs are:
global::Microsoft.Experimental.IdentityModel.Clients.ActiveDirectory.Resource.Id.agentWebView = global::MissionControlAuth.Droid.Resource.Id.agentWebView;
global::Microsoft.Experimental.IdentityModel.Clients.ActiveDirectory.Resource.Layout.WebAuthenticationBroker = global::MissionControlAuth.Droid.Resource.Layout.WebAuthenticationBroker;
The names of these missing resources suggest that I need to point the ADAL package to a webview that can be used to display a login page to the user. Unfortunately, I haven't been able to find any mention of this on StackOverflow or on the Xamarin forums. How can I correctly set up the ADAL package for my Xamarin.Forms PCL?
Platform / Library Versions
.NET Framework 4.5
Xamarin.Forms v2.0.0.6482 targeting Xamarin.Android and UWP
Visual Studio 2015
Microsoft.IdentityModel.Clients.ActiveDirectory v3.5.207081303-alpha (relevant answer)
Alternatively, Microsoft.Experimental.IdentityModel.Clients.ActiveDirectory v4.0.209160138-alpha (relevant answer)
Steps to Reproduce
Create a new Xamarin.Forms PCL project.
Choose one of the ADAL package versions above and add it to the PCL.
Add the same package version to the Xamarin.Android project. The library will install successfully, but there will be missing resource errors in the "Error List" tab in Visual Studio.
Experimental library is not supported. Please switch to MSAL available at https://www.nuget.org/packages/Microsoft.Identity.Client
I have a universal windows store app targeting Windows 10. In a previous version of the app targeting Windows 8.1 I used the LiveSDK (the 5.6 version here) to access data from the user's MS Live account using the LiveAuthClient. In the new version of the app, I figured I'd use the most recent version of the LiveSDK (5.6.3 available as a nuget package here) but when I install the nuget package, I am unable to to access the Microsoft.Live namespace.
For example, the following statement:
using Microsoft.Live;
Produces the error "The type or namespace 'Live' does not exist in the namespace 'Microsoft'"
Is this package broken or am I missing something obvious here? I would have expected this to work just like it did with the 5.6 version of the LiveSDK. It also seems like the documentation for the LiveSDK is all pointing to info about the OneDrive api now so it makes me wonder if the purpose of the sdk has changed. I'm confused... What's the most recent version of the LiveSDK (the one that has the LiveAuthClient) and where can I find it?
I'm not sure why Nuget Manager doesn't add a reference automatically, but it seems to work once you add a reference manually from directory:
C:\Users\USER\.nuget\packages\LiveSDK\5.6.3\WindowsXAML\MicrosoftLive.dll.
I have a github repo and a solution that's home to:
Common C# Library for domain / shared infrastructure
C# MVC 5 Web App
Xunit Test Project
Office App
This repo is connected to an azure site and automatically deploys the MVC Web App project.
Since i've added the Office App to the solution, the automatic deployment is failing with the error below.
Command: D:\home\site\deployments\tools\deploy.cmd
Handling .NET Web Application deployment.
Installing 'jQuery 1.9.1'.
Successfully installed 'jQuery 1.9.1'.
Unable to find version '1.1.0' of package 'Microsoft.Office.js'.
Failed exitCode=1, command="D:\Program Files (x86)\SiteExtensions\Kudu\1.26.30329.722\bin\scripts\nuget.exe" restore "D:\home\site\repository\src\MySolution.sln"
An error has occurred during web site deployment.
I'm not really sure as to why this could be happening as it's a pretty generic situation. It's also a perfectly fine nuget package: http://www.nuget.org/packages/Microsoft.Office.js/
Your link shows that the current version is 1.0.1
Office Javascript API 1.0.1
The Office JavaScript API includes objects, methods, properties, events, and enumerations that can be used from apps for Office to interact with Microsoft Office 2013 documents or mail items content.
Looking at your error log that contains this line:
Unable to find version '1.1.0' of package 'Microsoft.Office.js'.
It looks like in some config file you specified to use version 1.1.0.
Change that to 1.0.1 and it should be fine
Is there any foursquare client library available for Windows Phone 8. i checked the foursquare site and this client 'Sharp Square' but whenever i try to include it in my project i got the version incompatible error
install-package : Could not install package 'SharpSquare 1.0.0.2'. You are trying to
install this package into a project that targets 'WindowsPhone,Version=v8.0',
but the package does not contain any assembly references or content files that are
compatible with that framework.
i also tried adding the .dll after building the project but got the same error..
Loking at the source code of SharpSquare on GitHub (https://github.com/TICLAB/SharpSquare) there is no version that works with Windows Phone 8.
You need to convert it to a Windows Phone library. It should not be difficult, just removing the unnecessary references to System.Web and making all the request asynchronous. Here is my take on it, it compiles but I have not tested it: https://dl.dropboxusercontent.com/u/73642/SharpSquareWP8.zip
I think the best thing you can do is leverage Foursquare REST API https://developer.foursquare.com/docs/
And a library like RestSharp to work with them.