title: Is there an alternative for BuildManager.GetReferencedAssemblies() in ASP.NET Core?
body: <p>In ASP.NET MVC 5 I used the <code>BuildManager.GetReferencedAssemblies()</code> method to get all the assemblies in the bin folder and load them before the dependency started, so all the dlls were available to be scanned and injected.</p>
  
  <p>Is there an alternative in ASP.NET Core?</p>
  
  <p><a href="https://docs.microsoft.com/en-us/dotnet/api/system.web.compilation.buildmanager.getreferencedassemblies?view=netframework-4.7.2" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/dotnet/api/system.web.compilation.buildmanager.getreferencedassemblies?view=netframework-4.7.2</a></p>
  
  <p>I tried this code but it started do give me load errors, like file not found exceptions.</p>
  
  <pre><code>foreach (var compilationLibrary in deps.CompileLibraries)
  {
      foreach (var resolveReferencePath in compilationLibrary.ResolveReferencePaths())
      {
          Console.WriteLine($"\t\tReference path: {resolveReferencePath}");
          dlls.Add(resolveReferencePath);
      }
  }
  dlls = dlls.Distinct().ToList();
  var infolder = dlls.Where(x =&gt; x.Contains(Directory.GetCurrentDirectory())).ToList();
  foreach (var item in infolder)
  {
      try
      {
          Assembly.LoadFile(item);
      }
      catch (System.IO.FileLoadException loadEx)
      {
  
      } // The Assembly has already been loaded.
      catch (BadImageFormatException imgEx)
      {
  
      } // If a BadImageFormatException exception is thrown, the file is not an assembly.
      catch (Exception ex)
      {
  
      }
  }
  </code></pre>