Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Xamarin Forms fails to create an instance of DI container

$
0
0

I'm using Visual Studio 2017.

Created the default Xamarin Forms project (.net standard 2.0 + android). No changes in project configuration, Debug mode.

Compile -> Build -> Success (simple page with a standard text). Works in simulator, Xamarin Live.

Added Unity/Autofac and created an instance of the container in App. The solution works in simulator, but fails on phone (Xamarin Live, or direct execution).
This error can be reproduced in both Release/Debug modes.

With Unity:

public App ()
    {
        InitializeComponent();

        var c = new UnityContainer(); //this is the only line for Unity example
        MainPage = new App2.MainPage();
    }

Object reference not set to an instance of an object

p.s. tried the approach to skip linking assembly System.Core

With Autofac
Fails on RegisterType with exception:

Target of Add is null (NullReferenceException)


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>