title: Reading from appsettings.json file gives NullReferance Error
body: <p>I am trying to read some settings from my <code>appsettings.json</code> file but am getting a <code>NullReferenceException</code>. Using different SO posts as well as a few blogs I found on google I built the code and it all seems right, no compile errors and intillisense all works so I am not sure what I missed or did wrong.</p>
  
  <p>Startup.CS:</p>
  
  <pre><code>public class Startup
  {
      public IConfigurationRoot Configuration { get; set; }
  
      public Startup(IHostingEnvironment env)
      {
          //Set up configuration sources.
          var builder = new ConfigurationBuilder()
              .AddJsonFile("appsettings.json")
              .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
              .AddEnvironmentVariables();
  
          Configuration = builder.Build();
      }
  
      // This method gets called by the runtime. Use this method to add services to the container.
      public void ConfigureServices(IServiceCollection services)
      {
          services.AddMvc();
          services.AddCaching();
          services.Configure&lt;ApplicationSettingsModel&gt;(Configuration.GetSection("AppSettings"));
          services.AddScoped&lt;IApplicationSettings, ApplicationSettings&gt;();
  
          services.AddSession(o =&gt;
          {
              o.IdleTimeout = TimeSpan.FromSeconds(10);
          });
      }
  
      // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
      public void Configure(IApplicationBuilder app, IHostingEnvironment env)
      {
          if (env.IsDevelopment())
          {
              app.UseDeveloperExceptionPage();
          }
  
          app.UseExceptionHandler("/Error/ServerError");
          app.UseIISPlatformHandler();
          app.UseSession();
          app.UseStaticFiles();
          app.UseStatusCodePagesWithReExecute("/Error/PageNotFound");
          app.UseMvc();
      }
  
      // Entry point for the application.
      public static void Main(string[] args) =&gt; WebApplication.Run&lt;Startup&gt;(args);
  }
  </code></pre>
  
  <p>IApplicationSettings:</p>
  
  <pre><code>public interface IApplicationSettings
  {
      IOptions&lt;ApplicationSettingsModel&gt; AppSettings { get; }
  }
  </code></pre>
  
  <p>ApplicationsSettings.cs:</p>
  
  <pre><code>public class ApplicationSettings : IApplicationSettings
  {
      protected readonly IOptions&lt;ApplicationSettingsModel&gt; _AppSettings;
  
      public ApplicationSettings(IOptions&lt;ApplicationSettingsModel&gt; AppSettings)
      {
          _AppSettings = AppSettings;
      }
  
      public IOptions&lt;ApplicationSettingsModel&gt; AppSettings
      {
          get
          {
              return _AppSettings;
          }
      }
  
      public string GetAppVersion()
      {
          return _AppSettings.Value.AppVersion;
      }
  }
  </code></pre>
  
  <p>Model:</p>
  
  <pre><code>public class ApplicationSettingsModel
  {
      public string AppVersion { get; set; }
      public string BugZillaAPIKey { get; set; }
      public string EmailUser { get; set; }
      public string EmailPass { get; set; }
  }
  </code></pre>
  
  <p>Class making the call:</p>
  
  <pre><code>public class EHAL
  {
      private static IApplicationSettings _config;
  
      public EHAL(IApplicationSettings config)
      {
          _config = config;
      }
  
      public static string Test()
      {
          return _config.AppSettings.Value.AppVersion;
      }
  }
  </code></pre>
  
  <p>It is when I try to run <code>return _AppSettings.Value.AppVersion;</code> that the error is appearing. From the SO posts and blogs I think I am doing everything right but obviously I am screwing something up, just not sure what.</p>