title: ASP.NET Core ViewComponents in different assembly can not be found
body: <p>I'm trying to load a ViewComponent from a different assembly but in the main project I'm getting the error below</p>
  <blockquote>
  <p>InvalidOperationException: A view component named 'Pro.ItemViewComponent' could not be found. A view component must be a public non-abstract class, not contain any generic parameters, and either be decorated with 'ViewComponentAttribute' or have a class name ending with the 'ViewComponent' suffix. A view component must not be decorated with 'NonViewComponentAttribute'.</p>
  </blockquote>
  <h1 id="library.csproj-toye">Library.csproj</h1>
  <pre><code>&lt;Project Sdk=&quot;Microsoft.NET.Sdk&quot;&gt;
  
  &lt;PropertyGroup&gt;
  &lt;TargetFramework&gt;netcoreapp2.1&lt;/TargetFramework&gt;
  &lt;/PropertyGroup&gt;
  &lt;ItemGroup&gt;
  &lt;None 
  Remove=&quot;Views\Shared\Components\ContainerViewComponent\Default.cshtml&quot;/&gt;
  &lt;None Remove=&quot;Views\Shared\Components\ItemViewComponent\Default.cshtml&quot; /&gt;
  &lt;None Remove=&quot;Views\Shared\_ViewImports.cshtml&quot; /&gt;
  &lt;/ItemGroup&gt;
  
  &lt;ItemGroup&gt;
  &lt;Content 
  Include=&quot;Views\Shared\Components\ContainerViewComponent\Default.cshtml&quot;&gt;
    &lt;CopyToPublishDirectory&gt;PreserveNewest&lt;/CopyToPublishDirectory&gt;
    &lt;Pack&gt;$(IncludeRazorContentInPack)&lt;/Pack&gt;
  &lt;/Content&gt;
  &lt;Content Include=&quot;Views\Shared\Components\ItemViewComponent\Default.cshtml&quot;&gt;
    &lt;CopyToPublishDirectory&gt;PreserveNewest&lt;/CopyToPublishDirectory&gt;
    &lt;Pack&gt;$(IncludeRazorContentInPack)&lt;/Pack&gt;
  &lt;/Content&gt;
  &lt;Content Include=&quot;Views\Shared\_ViewImports.cshtml&quot;&gt;
    &lt;CopyToPublishDirectory&gt;PreserveNewest&lt;/CopyToPublishDirectory&gt;
    &lt;Pack&gt;$(IncludeRazorContentInPack)&lt;/Pack&gt;
  &lt;/Content&gt;
  &lt;/ItemGroup&gt;
  &lt;ItemGroup&gt;
      &lt;EmbeddedResource Include=&quot;Views/**/*.cshtml&quot; /&gt;
  &lt;/ItemGroup&gt;
  &lt;ItemGroup&gt;
    &lt;PackageReference Include=&quot;Microsoft.AspNetCore.App&quot; Version=&quot;2.1.1&quot; /&gt;
  &lt;/ItemGroup&gt;
  </code></pre>
  
  <h1 id="startup.cs-in-main-project-t0mp">Startup.cs in main project.</h1>
  <pre><code>var assembly = typeof(Pro.ItemViewComponent).Assembly;
  var embeddedFileProvider = new EmbeddedFileProvider(
      assembly,
      &quot;Pro&quot;
  );
  
  services.Configure&lt;RazorViewEngineOptions&gt;(options =&gt;
  {
      options.FileProviders.Add(embeddedFileProvider);
  });
  </code></pre>
  <p>I have followed many articles and some questions and answer in StackOverflow but I didn't find any solution, What should I do to share the ViewComponent from a different assembly?</p>