title: Dependency injection for non controller classes and calling them
body: <p>Trying to wrap my head around dependency injection, coming from the world of static classes and instantiated classes. Here is what I currently have:</p>
  <pre><code>[SomeFilter]
  public class AController : Controller
  {
      private readonly IOptions&lt;AppSettings&gt; _appSettings;
  
      public AController(IOptions&lt;AppSettings&gt; appSettings)
  {
      _appSettings = appSettings;
  }
  
  // GET: /characters/
  public IActionResult Index()
  {
      //do something
  }
  </code></pre>
  <p>SomeFilter gets called immediately, and does this:</p>
  <pre><code>public class SomeFilter: ActionFilterAttribute, IActionFilter
  {
       public override void OnActionExecuting(ActionExecutingContext filterContext)
      {
         OtherClass.RunMe();
      }
  }
  </code></pre>
  <p>OtherClass looks like this:</p>
  <pre><code>public class OtherClass
  {
      private readonly IOptions&lt;AppSettings&gt; _appSettings;
  
      public OtherClass(IOptions&lt;AppSettings&gt; appSettings)
  {
      _appSettings = appSettings;
  }
  
  public RunMe()
  {
      //do something
  }
  </code></pre>
  <p>I also have OtherClass registered as a service.Singleton in the Startup.cs.</p>
  <p>I get an error stating:</p>
  <blockquote>
  <p>&quot;An object reference is required for a non-static field&quot;</p>
  </blockquote>
  <p>for the <code>OtherClass.RunMe();</code> call.</p>
  <p>I was under the assumption that I can call this class from anywhere within my code instead of having to create a new instance of it? Essentially, how do I call methods from other classes using dependency injection?</p>