Cant use NuGet to add Unity IoC to a portable class library - windows-phone-8

I am making a Windows Phone 8 application, however because I would like at some point to also publish this application for Windows 8.1 store I made the effort to factor out the application logic into a portable class library. All good so far.
Now being a good boy I want to use an IoC container, unity by preference (since I am familiar with it in desktop and Win Phone 8 only apps)
So here's my problem; the NuGet Unity package will not install into my portable application with this result:
Installing 'Unity 3.0.1304.1'.
Successfully installed 'Unity 3.0.1304.1'.
Adding 'Unity 3.0.1304.1' to Logic.
Uninstalling 'Unity 3.0.1304.1'.
Successfully uninstalled 'Unity 3.0.1304.1'.
Install failed. Rolling back...
Could not install package 'Unity 3.0.1304.1'. You are trying to install this package into a
project that targets 'portable-net45+wp80+win', 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.
So is there a unity that works with a PCL? or is this just a shortcoming of the NuGet package?
I failed to find any useful documentation on the P&P website to indicate what platforms it is compatible with, but I know it does support WP8 at the least since the NuGet package is quite happy with libraries targeting just that.
Any guidance from the community would be very welcome here I don't want to abandon using a PCL for my app logic if I can avoid it, but if it comes down to a toss up between that and NuGet for package management I will in order to keep the NuGet goodness.
Could this be related to NuGet and Portable Class Libraries - Package doesn't target any framework? that seems more related to making your own NuGet packages for use in your own PCLs.

Unity 3.0.1304.1 does not contain any PCL assemblies so you will not be able to install it into a PCL project using NuGet.
The Unity NuGet package contains assemblies that target the following frameworks:
.NETFramework 4.5
.NETCore 4.5 (Windows Store/WinRT)
Windows Phone 8
You can see these target frameworks if you open the NuGet package into NuGet Package Explorer or download the NuGet package and open it using a program that supports zip files such as 7zip or Windows built-in zip file support.
So your possible options are:
Just use Unity in your main Windows Phone 8 application.
Write your own IOC container.
Use an IOC container that supports PCL projects such as Portable.CommonServiceLocator.
Compile your own PCL version of Unity.
Use a later version of Unity 3.5 since this includes a PCL assembly targeting portable-net45+wp80+win8+MonoAndroid10+MonoTouch10
Updated: 2014-05-11
Unity 3.5 now includes a PCL assembly that targets portable-net45+wp80+win8+MonoAndroid10+MonoTouch10 which will install into a project that targets portable-net45+wp80+win.

There is no Unity for PCL, but you can use Ninject for example.

Related

NU1202: MySql.Data.Entity isn't compatible with monoandroid81

I am trying to start my first Xamarin project and I got some issue while trying to install the MySqlEntity NuGet package.
Severity Code Description Project File Line Suppression State
Error NU1202 Package MySql.Data.Entity 6.10.8 is not compatible with monoandroid81 (MonoAndroid,Version=v8.1). Package MySql.Data.Entity 6.10.8 supports: net452 (.NETFramework,Version=v4.5.2) Refo_T3.Android C:\Users\evyat\source\repos\Refo_T3\Refo_T3\Refo_T3.Android\Refo_T3.Android.csproj 1
I tried this solution: Xamarin.Android: Package XX is not compatible with monoandroid81 (MonoAndroid,Version=v8.1)
and I still end up with errors.
It's my first application on Xamarin platform, I used to code in .NET but I decided to test my luck with Xamarin.
I couldn't find any more useful information online and I need your better experience.
Thank You :)
As written on the nuget packages page, the package is only available for .net framework >= 4.5.2
So you can't install it for Xamarin Android project only classic desktop .Net Framework applications.

Autofac.Mef and WinRT

I'm having troubles while trying to add the Metadata of Autofac. I have to install the package "Autofac Extras: Metadata Attribute Support" which need Autofac.Mef. When installing this package, I get a message saying that I try to install Autofac.Mef 4.0.0 in a project targeting «portable-net45+win+wpa81» and that the package doesn't contain any file supporting this. (Same message with Autofac.Mef 3.0.3).
I could probably find a way to make my project work without Autofac's Metadata but I don't understand why this package isn't compatible with Windows Phone 8.1. Is there a solution to this issue?
Thanks in advance
Thomas
If you download the Autofac.Mef package manually and then open it up in NuGet Package Explorer you'll see that the Autofac.Mef package only targets .NET 4.5 apps - you can't use it in Windows Phone.
The reason for this is that the original framework MEF is only compatible with the full .NET framework. There's a "lighter weight" MEF 2 framework that is compatible with Windows Phone 8.1 but that's not the one Autofac.Mef works with.
There's no way to fix it. There's also no current plan to switch Autofac.Mef to using the Microsoft.Composition package.

Windows Universal App SQLlite in Portable DLL

My project structure is defined like this:
LIB Com basic communication, (requests and responses)
LIB Com.BackgroundTask background task that will fetch new messages from server
LIB Com.Mediator background logic that will handle every exchange of information and interaction between Com and the ViewModel
LIB Model all Models for the Project, also the Databases should be defined here.
LIB Settings App settings.
Windows App Views/Controls for Windows
Windows Phone App Views/Controls for Windows Phone
Shared Basic App logic, Mediator init, ViewModels
the Problem is that you cannot reference the SQLLite extension in the (Portable) LIB Model but this is essentialy for the project structure to work. Otherwise the BackgroundTask would never be able to update the Database, am i right?
You can refer SQLite in a portable class library project using Portable Class Library for SQLite. This project has been initiated by Microsoft Open Technologies, Inc. working with the community.
This portable class library for SQLite available as NuGet package
simplifies the installation and development experience for .NET
developers by providing a single interface across Windows Phone,
Windows Store and .NET Framework 4.5.
With this solution .NET developers can develop against one portable
class library and do not have to worry about what assembly is loaded.
Drawback: Targeting x64 platform architecture is not supported at the moment.
Targets supported: x86, and AnyCPU (with "Prefer 32-bit" option marked).
Pre-requisites:
1) The developer visits http://sqlite.org/download.html, and downloads the required precompiled binary for Windows v3.8.5 (http://sqlite.org/2014/sqlite-dll-win32-x86-3080500.zip), extracts the sqlite3.dll file, and adds it as Copy-Always Content to the root folder of the project.
2) In Visual Studio, the developer uses NuGet Packet Manager Console to install the SQLitePCL wrapper package.
Inside the Package Manager Console, type: Install-Package SQLitePCL

Error Adding MvvmCross NuGet package to PCL in VS2013

When I try to install MvvmCross on my PCL, I get the error message below. I am running Visual Studio 2013 and the Xamarin Frameworks are installed for the PCLs.
I'm using Profile78, which targets .net framework 4.5, windows store apps (windows 8) and higher, Windows Phone 8, Xamarin.Android, and Xamarin.iOS.
Is there a better profile for me to use?
Could not install package 'MvvmCross.PortableSupport 3.0.13'. You are trying to install this package into a project that targets 'portable-net45+wp80+win+MonoAndroid10+MonoTouch10', 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.
This area is changing with many new releases from many different places. I don't believe there are any definitive answers here today. There's a walkthrough using the latest platforms on http://slodge.blogspot.co.uk/2013/11/quick-run-through-using-pcls-in.html
That walkthrough uses:
Xamarin - iOS 1.8 & Android 4.10
Nuget - 2.7.2
MvvmCross - 3.0.14-beta3
Visual Studio 2012
portable profile 158
Other setups may also work - I don't know if anyone knows which is "better" - but it would be interesting to hear opinions!

Does protobuf-net support Windows RT?

Is it possible to use the protobuf-net library in an application that targets Windows RT? I tried adding it via NuGet to my project but I receive this error:
Successfully installed 'protobuf-net 2.0.0.480'.
Successfully uninstalled 'protobuf-net 2.0.0.480'.
Install failed. Rolling back...
Could not install package 'protobuf-net 2.0.0.480'. You are trying to install this package into a project that targets '.NETCore,Version=v4.5', but the package does not contain any assembly references that are compatible with that framework. For more information, contact the package author.
You need a newer version. Version 594 has support for 4.5.
In the package manager console (Tools->Library Package Manager->Package Manager Console) run:
PM> Install-Package protobuf-net -Version 2.0.0.594
Or download it from the project web site.
Yes, the more recent builds have full support for .NETCore (aka "WinRT", "Windows Store Applications", or "Metro", or "Modern UI", or whatever they want to call it today). As Eli notes, you can obtain it by specific version, or you can get it from the google-code download.
Note that for the best performance it is recommended to use "precompile", the new precompiler, because .NETCore has no support for meta-programming: without this, it will be using reflection at runtime, and will not be anywhere near as fast as it can be. This is included in the google-code download.