title: Dependency Injection calls in Libraries .NET Core
body: <p>What is the correct way for a Libary to call an object that was injected through Dependency Inject?</p>
  
  <p>Background: I have multiple .NET Core app that uses dependency injection for all major objects and uses libraries for reusability.  It is working great.  App1 calls Libary1 and Libary2. App2 calls Libary2 and Libary3 etc.  </p>
  
  <pre><code>service.AddTransient&lt;Libary1.ILibary1Dependency, Libary1.Libary1Dependency&gt;();
  service.AddTransient&lt;Libary2.ILibary1Dependency, Libary2.Libary1Dependency&gt;();
  service.AddTransient&lt;Libary2.ILibary2Dependency, Libary2.Libary2Dependency&gt;();
  service.AddTransient&lt;Libary3.ILibary1Dependency, Libary3.Libary1Dependency&gt;();
  </code></pre>
  
  <p>Now in <code>Libary2.ILibary1Dependency</code> there is a method that needs to call a new <code>Libary2.ILibary2Dependency</code>.  What is the best way to do this?</p>
  
  <p>Should I just do a <code>new Libary2.ILibary2Dependency(property1, property2...);</code>?  </p>
  
  <p>Is it ok in the main app to actually inject the <code>IServiceCollection</code> object and then in the constructor of the <code>Libary2.ILibary1Dependency</code> get the <code>IServiceCollection</code>?</p>
  
  <p>Is there some nugget package that I don't know about that fixes this perfectly?</p>
  
  <p>Note: <code>Libary2.ILibary2Dependency</code> does get called on its own via dependency injection, if you were wondering</p>