Azure Storage Account nuget Package doesn't target MonoAndroid - xamarin

I'm creating an Android app using Xamarin with Visual Studio. I want to install the Windows Azure Storage nuget package but it's failing to install because the System.Diagnostics.Tools package it depends on doesn't target the MonoAndroid framework. Is there a way around this? Could there be something wrong with my configuration?

Make sure your are adding Nuget package 'WindowsAzure.Storage.7.0.0' as older versions did not support PCL Profile 111 and thus Xamarin.
Package.config:
<package id="WindowsAzure.Storage" version="7.0.0" targetFramework="monoandroid51" />
Microsoft Azure Storage SDK for .NET (7.0.0)
Target Frameworks
Portable Class Library Profile 111: Storage Client Libraries are available to support building PCL Profile 111 applications, as well as for Xamarin application development. This support is currently in preview.

Related

Using platform specific httclienthandler?

In xamarin should I always configure the app to use the platform specific httpclienthandler or is it ok to use the default httpclienthandler. I have read that you get better performance but I was just wondering if it is so much better that this should be a standard practice for all my xamarin apps.
It is ok to use httpclienthandler in the portable class library(pcl). Feel free to use HttpClient to run in a PCL library that supports iOS, Android, and WP8.
Here how i did it. Restart from a clean project.
Create a PCL with iOS, Android, .NET 4.5 and WP8. Add the microsoft Http nuget. It will install 2 other packages into the PCL.
Create the Android and iOS projects. Reference your PCL in both projects. For me that's all. It just works.
You may add the reference "System.Net.Http" in both platform projects. The reference is under Assemblies/Framework.
NEVER add Microsoft.Http nuget in any native project, nor the BCL nuget. It will create mess and you'll have to clean lots of things before it can work again.
It is extremely important that your NuGet manager is up to date, go to Tools-> Extensions and updates -> Updates

Cannot install Simple OData Client in Xamarin.Forms

This suggested Nuget Client will not install on Visual Studio 2017 for Mac. When I attempt to install, I receive the following error message:
"Could not install package 'Microsoft.OData.Edm 6.0.0'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.5,Profile=Profile111', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author."
The link to this Nuget package is https://components.xamarin.com/view/simple.odata.client.
When trying to install other Nuget packages I receive a similar error message naming a different package as the error source.
It looks like you're mixing a couple of things. The Simple.OData.Client package is not the Microsoft.OData.Edm package. Also you say you link to a NuGet package, put you link to the Xamarin Component Store.
Furthermore, I think you should read up on what PCLs are and how to use them. When I look at the NuGet page for the Microsoft.OData.Edm package I see that it does not support iOS and Android. So, you will never be able to install it to a PCL which targets one of these platforms. You should, however, be able to install the Simple.OData.Client package according to the NuGet page.
PCLs have a certain profile. When you right-click and go to the properties of a PCL library, you can check all platforms that you want it to support. Each combination of platforms have a certain profile, specified by a three digit number, like 111 or 259. The parts of the .NET framework that are available to you, are an intersection of the functionalities that are available on all targeted platforms. If a functionality is supported by iOS but not on Android, it's not supported in your PCL.
This is also why NuGets need to support the specific profile that you are targeting, because it can only use the methods that are available in it.

C# Nuget References

I'm a bit confused about the dlls that are installed when using Nuget to install libraries to my Xamarin Projects. I mainly manage the nugets for the whole solution. So when i install a nuget i choose all platform projects as targets, meaning the PCL, the Android and the iOS Project. In most cases there are different dlls, like #.XForms, #.XForms.Android and #.Android, for example in the Community Toolkit (FormsCommunityToolkit), which is also available from Nuget.
In my understanding the .Android dlls need to be used in the android platform project, and the XForms dll without android should be used in the PCL. A good example is the Converters.dll. That's code only used in the pcl, but the dll is also automatically referenced in the platform projects. So my question is, why is this the case?
I see this behavior not only for this toolkit but also for other apis, like Syncfusion.
PCL dlls will contain codes that accessing common API for the targeted PCL profiles. For the UI project (Android and iOS) need to be using different dlls most of the time because it need to access to platform specific APIs. For example, API to check network connection is different in iOS and Android.
But you should not be worry about which dlls to use. NuGet package manager already handle which dlls to be use in the solutions. So, you will just need to include the packages and let the package manager to handle the rest of it.

Xamarin.Forms Package Erorr

Has anyone encountered this error when adding the Xamarin.Forms package through the "Add NuGet package" option?
PS I'm using Xamarin Studio and I only encounter this with Windows.
Error message is:
Could not install package 'Xamarin.Forms 2.2.0.31'. You are trying to
install this package into a project that targets
'.NETFramework,Version=v4.5,Profile=Profile78', but the package does
not contain any assembly references or content files that are
compatible with that framework.
Here is the screenshot
You are having a profile which has portable class Profile78.Profiles are the type of your portable class where you select the target projects which can use your PCL. The more you select the less functionality can be provided.
You need to change it to another one. Usually most classes (including Xamarin.Forms) are supporting Profile111. Profile111 is a profile which does not support Silverlight in contast du Profile78. So you need to go to Properties and deselect Windows Phone Silverlight and Silverlight. You can select everything else (.Net 4.5, Windows 8, Windows Phone 8.1, Android, iOS/iOS classic and ASP.NET Core 1).
Then try adding Xamarin.Forms again.
You can see more information with a list of all(?) profiles here.
Here you see how to change in Visual Studio project Properties:
And here in Xamarin Studio project Option:
The problem is that you do not have the Portable Class Library (PCL) profiles installed on Windows. Xamarin.Forms 2.2.0.31 supports Profile78 so changing it to Profile111 will not fix the problem.
The error message itself indicates that this is the problem since it refers to Profile78. If the NuGet package was really incompatible then NuGet would show the frameworks in the PCL profile in its error message not the profile number. If I try to install Xamarin.Forms 2.2.0.31 into a PCL project that targets Profile1 which is not supported by Xamarin.Forms then I get an error:
Could not install package 'Xamarin.Forms 2.2.0.31'. You are trying to install this package into a project that targets 'portable-net40+sl40+win+wp+Xbox40', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.
Note that Profile1 is not mentioned.
There are detailed instructions on installing Portable Class Libraries for Xamarin Studio which I will summarize here:
To install the Portable Class Libraries on Windows you have three options:
Install Visual Studio 2013 (full or Express version). Update 2 or
above is required.
Install the Portable Library Tools and the Portable Library Reference Assemblies 4.6.
Install the Portable Library Tools and copy the .NETPortable directory from Mono over to Windows.

Add async await support for PCL library

I'm creating PCL library to be used at Windows Store 8.0 and Windows Phone 7.5 clients.
I created new PCL project and chose the following:
https://dl.dropboxusercontent.com/u/19503836/pcl_profile4.png
Selected profile covers .net 4.5 and silverlight 4.0 thus they were enabled automatically.
As a result I have Profile4 selected but when I'm trying to add Async nuget package to PCL project:
http://www.nuget.org/packages/Microsoft.Bcl.Async
I'm getting an error that this profile is not supported:
Attempting to resolve dependency 'Microsoft.Bcl (≥ 1.0.19)'.
Attempting to resolve dependency 'Microsoft.Bcl.Build (≥ 1.0.4)'.
'Microsoft.Bcl.Build 1.0.10' already installed.
'Microsoft.Bcl 1.0.19' already installed.
'Microsoft.Bcl.Async 1.0.16' already installed.
Adding 'Microsoft.Bcl.Build 1.0.10' to PortableClassLibrary1.
Could not install package 'Microsoft.Bcl.Build 1.0.10'. You are trying to install this package into a project that targets 'portable-win+net45+sl40+wp', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.
How to create PCL library and add Async/Await support WITHOUT cheating the *.csproj file (I know I can specify profile there but I need to be able to it via UI for DEMO purposes).
Your project is targeting Windows Phone 7.0, not 7.1/7.5. Change your target to "Windows Phone 7.5 and higher".
For best results, uninstall all NuGet packages, change your targets, and then re-install your NuGet packages.

Resources