title: You MUST call Xamarin.Forms.Init(); prior to using it
body: <p>In my app.xaml.cs I create a new page.</p>
  
  <pre><code> public App()
    {
        InitializeComponent();
        MainPage = new NavigationPage(new WrapLayoutPage());
    }
  </code></pre>
  
  <p>This page calls a static class, which uses the DependencyService to perform some tasks. </p>
  
  <p>The line which throws the error:</p>
  
  <pre><code>var tmpTable = SqLiteHelper.GetItem&lt;TableX&gt;("someId");
  </code></pre>
  
  <p><strong>SqLiteHelper:</strong></p>
  
  <pre><code>public static class SqLiteHelper
  {
      private static readonly SQLiteConnection DatabaseConnection = DependencyService.Get&lt;ISqLite&gt;().GetConnection();
      private static readonly object Locker = new object();
  
      public static DbObjectV3 GetItem&lt;T&gt;(Guid inId) where T : DbObjectV3, new()
      {
          lock (Locker)
          {
              var tmpItem = DatabaseConnection.Table&lt;T&gt;().FirstOrDefault(inItem =&gt; inItem.Id == inId);
              tmpItem.IsNewObject = false;
              return tmpItem;
          }
      }
  }
  </code></pre>
  
  <p>This throws me a <code>TypeInitializationException</code> with the InnerException: </p>
  
  <blockquote>
    <p>You MUST call Xamarin.Forms.Init(); prior to using it</p>
  </blockquote>
  
  <p><strong>It's somehow related to the static helper class, because prior to that call, I can use the DependencyService without any problems!</strong></p>
  
  <p>As mainlauncher I'm using a splash screen. In this class I do some startup work, which relies on the DependencyService.</p>
  
  <p><strong>SplashScreen:</strong></p>
  
  <pre><code> [Activity(Theme = "@style/MyTheme.Splash", NoHistory = true, MainLauncher = true)]
      public class SplashScreen : Activity
      {
          static readonly string TAG = "X:" + typeof(SplashScreen).Name;
  
          public override void OnCreate(Bundle savedInstanceState, PersistableBundle persistentState)
          {
              base.OnCreate(savedInstanceState, persistentState);
              Log.Debug(TAG, "SplashActivity.OnCreate");
          }
  }
  </code></pre>
  
  <p><strong>My MainActivity:</strong></p>
  
  <pre><code> [Activity(Label = "FrameworkForms", Icon = "@drawable/icon", ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation, Theme = "@style/MainActivityTheme", MainLauncher = false)]
      public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
      {
          protected override void OnCreate(Bundle bundle)
          {
              base.OnCreate(bundle);
              Xamarin.Forms.Forms.Init(this, bundle);
              App.ScreenWidth = (double)(Resources.DisplayMetrics.WidthPixels / Resources.DisplayMetrics.Density);
              LoadApplication(new App());
          }
      }
  </code></pre>
  
  <p>Now after changing the <em>Activity</em> in SplashScreen to <em>FormsAppCompatActivity</em>, I get another error.</p>
  
  <blockquote>
    <p>Call Forms.Init() before Hide Keyboard</p>
  </blockquote>
  
  <p>What's the thing here?</p>