title: How to implement dependency injection in an MSTest project using Startup.cs and Assembly
body: <p>In our application, I have used Visual Studio 2017 .NET Core 2. I have implemented dependency injection in a Web project <code>Startup.cs</code> class. I have to implement the same in a new test project. How can I inject dependencies of repositories in the test project?</p>
  
  <p>Please see the below code snippet</p>
  
  <pre><code>using Microsoft.AspNetCore;
  using Microsoft.AspNetCore.Hosting;
  using NLog.Web;
  
  namespace Kpmg.Kdat.Data.Services.Directory.Tests
  {
      public class Program
      {
          public static void Main(string[] args)
          {
              BuildWebHost(args).Run();
          }
  
          public static IWebHost BuildWebHost(string[] args) =&gt;
              WebHost.CreateDefaultBuilder(args)
                  .UseStartup&lt;Startup&gt;()
                  .UseNLog()
                  .Build();
      }
  }
  </code></pre>
  
  <p>The purpose of the above code is to inject dependencies. In <code>Startup.cs</code> I have configured all the dependencies.</p>
  
  <p>While using the above code I am getting the below error:</p>
  
  <blockquote>
    <p>Error    CS0017    Program has more than one entry point defined. Compile with /main to specify the type that contains
    the entry point.</p>
  </blockquote>
  
  <p>How can I fix the issue?</p>