title: TagHelpers not working when assembly is dynamically loaded in ASP.NET core 2.1
body: <p>I'm using ASP.NET core 2.1. I load all the assemblies that have the Views dynamically from a <strong>plugins</strong> folder. I use the following code for that. The Views get loaded correctly.</p>
  
  <pre><code>services.AddMvc().
      AddRazorPagesOptions(o =&gt; o.AllowAreas = true).
      SetCompatibilityVersion(CompatibilityVersion.Version_2_1).
      ConfigureApplicationPartManager(ConfigureApplicationParts);
  
  private void ConfigureApplicationParts(ApplicationPartManager apm)
  {
      var pluginsPath = Path.Combine(_env.WebRootPath, "Plugins");
  
      var assemblyFiles = Directory.GetFiles(pluginsPath, "*.dll", SearchOption.AllDirectories);
  
      foreach (var assemblyFile in assemblyFiles)
      {
          var assembly = Assembly.LoadFile(assemblyFile);
  
          if (assemblyFile.EndsWith(".Views.dll"))
          {
              apm.ApplicationParts.Add(new CompiledRazorAssemblyPart(assembly));
          }
          else
          {
              apm.ApplicationParts.Add(new AssemblyPart(assembly));
          }
      }
  }
  </code></pre>
  
  <p>The views have some custom taghelpers.</p>
  
  <p>The <strong>_ViewImports.cshtml</strong> file looks like</p>
  
  <pre><code>@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
  @addTagHelper *, MyTagHelpers
  </code></pre>
  
  <p>The problem is that the custom tag helpers don't get loaded and gives an error:</p>
  
  <blockquote>
    <p>Error: Could not load file or assembly MyTagHelpers</p>
  </blockquote>
  
  <p>The reason I get the error may be the Razor View Engine may be looking for the DLL in the <strong>bin</strong> folder of the main app and it can't find the DLL and gives this error.</p>
  
  <p>What should I do in the startup to say the taghelpers are available in a DLL and can be loaded from there? Should I use <a href="https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.mvc.razor.taghelpers.taghelperfeatureprovider?view=aspnetcore-2.1" rel="nofollow noreferrer">TagHelperFeatureProvider</a> to do it?</p>
  
  <p><strong>UPDATE:</strong> I moved the tag helpers to a separate DLL called <strong>MyTagHelpers.Common</strong> and dropped in the plugins folder. I'm not getting any assembly not found error anymore, but the tag helpers are not working.</p>