1
votes

I am new to Xamarin Forms and am trying get Microsoft Unity IoC framework integrated into it for use in an iOS/Android app.

Adding the Nuget package is simple enough but as soon as I add something that actually references Unity (e.g. public static UnityContainer Container { get; private set; }), my app dies at runtime with a

However, when I go to run it, my app dies immediately with a FileNotFoundException of Microsoft.Practices.ServicesLocation

Best I can tell my project is setup similar to this tutorial project.

1
Which project did you add the nuget package to? You have to add it to the PCL, Android, and iOS. - Andres Castro
I added it to every PCL and the *.iOS and *.Droid projects. Clean, rebuild, same result. Regardless shouldn't the references cascade down (like in Visual Studio)? - Ternary
I have had issues were it doesn't build them in. Can you also check if nuget.org/packages/CommonServiceLocator is installed? - Andres Castro
Unity has a soft reference to Common Service Locator which seems to be causing an issue. If you manually install the CommonServiceLocator nuget package it should be OK. - Randy supports Monica
Randy you were correct. Though I did have to add the reference to both the PCL and the .iOS app. If you write that up as an answer, I'll gladly accept it. Thanks - Ternary

1 Answers

1
votes

Unity has a reference to Common Service Locator but the NuGet package does not have it as a dependency. I believe this is by design (but I can't find it documented right now).

Usually this isn't an issue unless using UnityServiceLocator but it is causing an issue for you. If you manually install the CommonServiceLocator NuGet Package it will resolve the issue.