Azure Mobile Services in a PCL project that includes WP8 - c#

Is it possible to inlcude AzureMobileServices client in a PCL that includes WP8?
I used to have a PCL project that had it up until I upgraded it to VisualStudio 2013.
The required PCL is profile78: .NET4.5, Windows Store apps (Win8), WP8, and the Xamarin twins.
I tried following this recommendation from Xamarin to reference the component's DLL directly, however the DLL was compiled for profile7 (that does not include WP8).

Yes. Make sure you are using at least version 1.1.5 of the Mobile Services NuGet package or Xamarin Component and you will be able to successfully use it from a PCL that includes WP8. For a tutorial on how to do this, see here.

It looks like their nuget package only includes directories for Store, .Net 4.5, Wp8, and Portable-Store+.Net 4.5. However if I ildasm the dll in the portable folder I see it was built for Profile78, which does support phone.
This looks like a bug with the WindowsAzure.MobileServices.nupkg nuspec authoring.

Related

Unable to add ZXing.Net.Mobile package to my Xamarin.Forms project

I have an Xamarin.Forms project in which I want to use ZXing library for barcode scanning. However I am unable to install package ZXing.Net.Mobile and ZXing.Net.Mobile.Forms into my portable project. The exception I keep getting is as follows:
Could not install package 'ZXing.Net.Mobile 2.0.4.46'. 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.
Any ideas on how to solve this?
I took a quick look at the package contents, and the package is not completely targeting PCL Profile 111 (.NET Framework 4.5, Windows 8, Windows Phone 8.1) according to the folder name. The portable library is located in the folder:
lib/portable-net45+netcore45+wp8+UAP10.0+MonoAndroid403+MonoTouch10+Xamarin.iOS10
which is missing out wpa81 (i.e. Windows Phone 8.1 non-Silverlight) to be compatible with PCL Profile 111.
Since netcore45 and UAP10.0 are included in the folder name, I suspect that the missing wpa81 specification is just an oversight by the package authors and could be added to the folder name without problems. Of course, this has to be confirmed with the package authors, and they would need to update the NuGet package.
As a side note, I also believe the folder name is a little bit "overdone". For maximum compatibility, I think it would be better to exclude the UAP and Xamarin specifications. NuGet targets these platforms automatically if standard lib folder naming conventions are used.
If you don't need Windows Phone 8.1, as per Denis Vitez comment above, changing to Profile 7 allows you to install ZXing.Net.Mobile and ZXing.Net.Mobile.Forms.

Unsupported PCL Profile in Xamarin

I am working with the GoPro camera and trying to run a library made by r1pper. The project is described as
A lightweight c# library to access and control GoPro HERO Action cameras
It has a functional media browser based on Ambarella and GoPro App, it has also the full control of the camera, and live preview.
I am having trouble when trying to compile on the Xamarin IDE:
/Library/Frameworks/Mono.framework/Versions/3.10.0/lib/mono/4.5/Microsoft.Common.targets: Error:
Unsupported PCL Profile '.NETPortable,Version=v4.0,Profile=Profile96'. (GoPro.Hero)
I have looked at a couple of forums and blogs that mention there is no fix for this bug:
http://forums.xamarin.com/discussion/164/pcl-build-problems
http://forums.xamarin.com/discussion/6334/problem-with-pcl-support-after-update
Is there really no workaround to this bug? Or am I misunderstanding something?
It looks like Profile 96 is not available in Mono.
I would change the Portable Class Library (PCL) project so it targets a different profile that is available on Mono. I would pick Profile 78 or Profile 259 since these are the ones generally recommended by Xamarin. You can do this in the Project Options under Build - General.
You may need to reinstall/retarget the NuGet packages after changing the project's PCL profile. If you are using a recent version of Xamarin Studio then it should tell you if this is the case in the Package Console window.
If I'm not mistaken you didn't install Visual Studio 2012/2013 (which Automatically configure MSBuild for PCL usage), in this case you should install and configure PCL on your system manually (it is only needed for development, not for distribution)
Here are the steps based on this Guide
1- Install .NET Framework 4.5.1
2- Install Mono MDK
3- Install PCL Library Tools : it will install MSBuild tools and Profile96
4-(Optional) Install PCL Reference Assemblies for newer PCL profiles
after installation copy 4.6 PCL assemblies from
C:\Program Files (x86)\Microsoft .NET Portable Library Reference Assemblies 4.6\PortableReferenceAssemblies.zip
to
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETPortable
5-Reinstall Xamarin Suite

PCLStorage in Windows Phone 8

I'm using PCLStorage for a Win8/Wp8 project I'm working on. I'm using it within a PCL itself, and have it referenced in my Win8, Wp8 and PCL projects. Everything is working great in Win8.
In Wp8 however, once I hit my PCL for storage which uses PCLStorage, I'm getting a NotImpmlementedException when I call FileSystem.Current;
"This functionality is not implemented in the portable version of this assembly. You should reference the PCLStorage NuGet package from your main application project in order to reference the platform-specific implementation."
But like I said, I have the PCLStorage NuGet package referenced in my Wp8 project AND the PCL project the same way I do in my Win8 project.
Any idea what's happening?
(I should also note that PCLStorage is working fine if I use it in a new Wp8 project)
Try uninstalling the PCLStorage NuGet package from all projects and then reinstalling it in all of them.
If it still doesn't work, try checking the references to the PCLStorage DLLs in the WP8 project and make sure they are coming from the wp8 folder in the package.
If that doesn't lead anywhere, try setting copy local to false in the references from your PCL to the PCL Storage DLLs. If you have to do that it's an issue that needs to be fixed, so please file a bug for it.
EDIT: There is a bug in VS 2013 Update 2 RC that can cause this problem. This NuGet package is supposed to fix the issue if you reference it in your Windows Phone app: SuppressPackagingPclFacades. Alternatively setting Copy Local to false for the reference from your PCL library to the PCL Storage assemblies should also fix the issue.

HttpClient missing from .Net portable subset while creating PCL in Xamarin

I have created a Portable class library in Xamarin and want to use it for an android app. I want to use the HttpClient within this PCL. I have added the Microsoft Http Client libraries from the NuGet Package manager. I can now see the .Net portable subset added to my references. But somehow I still cannot use the HttpClient and it does not show in the .Net portable subset as well.
Also, my Current profile of the PCL is 4.0-Profile 158. If I change the profile to 4.5, Xamarin crashes and does not open the solution
Can anyone help me with this?
Thanks
The simple solution is to target .NET 4.5, Windows Store apps (Windows 8.1), Xamarin.iOS, and Xamarin.Android (4.5-Profile7). Then you won't need the HttpClient NuGet package to get those APIs.
If Xamarin is crashing when you try to select a 4.5 profile, please make sure you're using the latest version and then report the bug with details about how to repro it and what happens.
Also the HttpClient NuGet package should allow you to use HttpClient from PCL profile 158. Make sure you're using the latest version of NuGet. ".NET Portable Subset" should always appear in your references for a PCL, that's not related to the NuGet package. When you install the HttpClient NuGet package, you should also see references to System.Net.Http and other assemblies in your references.

Why can't I use await keyword in my Windows Phone 7.1 MvvmCross project while using the Microsoft.Bcl - cannot await 'System.Threading.Tasks.Task?

I am unable to use the await keyword in my MvvmCross Windows Phone 7.1 project while using the Microsoft.Bcl "Microsoft BCL Portability Pack".
I have posted the code for the sample project that I describe below on GitHub and the await error occurs on this line.
When I try to build the third "Core" Windows Portable Class Library (PCL) that contains the FirstViewModel, I get the errors of:
Type System.Threading.Tasks.Task<string> not awaitable under VS red squiggles, and
Cannot await 'System.Threading.Tasks.Task<string>' when building.
There are four projects in the solution:
A Windows Portable Class Library (PCL) with an interface in it that
references that "Task" object provided by the BCL.
A Windows Phone Class Library targeting OS 7.1 that implements the
interface above and also uses "Task" from the BCL.
Another Windows Portable Class Library (PCL) that provides the
"Core" functionality of the app, including the ViewModel.
The Windows Phone 7.1/"7.5" application that tries to reference and
consume the DLL's above.
The first two projects containing the interface and the implementation of the interface compile without any errors. But the 3rd "Core" PCL fails to build with the errors shown above.
More Details If You Want Them:
I tried this App.config "fix" as described here in the "known BCL issues":
http://blogs.msdn.com/b/bclteam/p/asynctargetingpackkb.aspx .But that did not resolve the error when I added App.config to just the "Core" project, nor when I tried to add the same App.config to every project. It is possible that I am not using the right version in the element or I just did the App.config stuff incorrectly.
Every project in the solution that is set to target a PCL are set to "Profile104" in Visual Studio.
Those DLL's are located in:
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETPortable\v4.0\Profile\Profile104\
This PCL profile is shown as targeting these platforms in the Visual Studio project properties:
.NET for Windows Store apps, .NET 4.5, Silverlight 4+, and Windows 7.5+
Every project in the solution also has reference to the Microsoft.Bcl "Microsoft BCL Portability Pack" via NuGet.
All four projects are using MvvmCross (Mvx).
None of the projects in this sample are trying to target anything related to the Xamarin Droid/iOS stack yet. It is all Windows and is still failing on the await keyword.
The PCL with the interface in it and the Windows Phone Class Library both use the Mvx CrossCore NuGet Package and are setup to be consumed as "Mvx Plugins".
The "Core" PCL is using the full MvvmCross NuGet package and contains the FirstViewModel where the await error is occurring.
The Windows Phone App project references the full MvvmCross as well, with the Windows Phone-specific Mvx files pulled in to it.
as mentioned, see the failing sample code on GitHub.
You need to add the Microsoft.Bcl.Async NuGet package.
These packages were previously unavailable on non-Microsoft platforms, but as part of the Xamarin collaboration Microsoft relicensed them to be usable under all platforms.

Categories