Search code examples
performancexamarin.formsunity-containerprism-6dryioc

Xamarin Forms, Prism Forms & IoC


I have a Xamarin Forms application that I originally developed using Prism and Unity. I am finding Unity to be rather slow when first resolving an object though once that first time has passed all subsequent resolutions of the same object type are significantly quicker.

Based upon some unrelated advice I received on another thread I decided to try swapping from Unity to DryIoc. Unfortunately I am finding this to be even slower when resolving objects but without the speed improvement when subsequently resolving new instances of those same object types.

So, my question is this, is there anything that I can do with either of the containers that will improve the performance? For example...

  • Is there anything within Unity that will allow me to pre-configure the objects that are likely to be created so that the first resolution is as fast as the subsequent resolutions?
  • Is there anything I can do with DryIoc that will speed up all object resolutions?

For reference, my own usage of each is very simple; I am using RegisterInstance for most of my objects (settings, database etc.) and injecting them into my ViewModel objects through the constructors. The Forms and ViewModel objects themselves are all registered using the Prism RegisterTypeForNavigation extension method


Solution

  • The problems I was seeing were not related to the IoC containers but instead a problem with Xamarin that was introduced at the beginning of May with the 15.2 update of Visual Studio. Installing the latest update (15.2.26430.12) and rebuilding the solution restored the kind of performance that I was expecting.