title: InvalidOperationException: The view was not found
body: <p>I have an ASP.Net project and I want to use a class library project for creating reusable Razor view components. I added <code>AspNetCore.Mvc</code> and <code>AspNetCore.Razor.Tools</code> references to my class library project.</p>
  
  <p>I create the <code>ViewComponent</code> class inside <code>Components/DataTableComponent.cs</code> file:</p>
  
  <pre><code>namespace Rasha.Utility.Components
  {
      public class DataTableComponent:ViewComponent
      {
          public async Task&lt;IViewComponentResult&gt; InvokeAsync()
          {
              var model = new DataTableModel()
              {
                  Name = "Alliiiiiiiiiiiiiiiii"
              };
              return View("Default.cshtml", model);
          }
      }
  }
  </code></pre>
  
  <p>And view inside <code>Views/Shared/Components/DataTableComponent/Default.cshtml</code> file.</p>
  
  <p>This is my class library .csproj file:</p>
  
  <pre><code>&lt;Project Sdk="Microsoft.NET.Sdk"&gt;
    &lt;PropertyGroup&gt;
      &lt;TargetFramework&gt;netcoreapp1.1&lt;/TargetFramework&gt;
    &lt;/PropertyGroup&gt;
    &lt;ItemGroup&gt;
      &lt;PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.2" /&gt;
      &lt;PackageReference Include="Microsoft.AspNetCore.Razor.Tools" Version="1.1.0-preview4-final" /&gt;
    &lt;/ItemGroup&gt;
  
    &lt;ItemGroup&gt;
      &lt;EmbeddedResource Include="Views\Shared\Components\**\*.cshtml" /&gt;
    &lt;/ItemGroup&gt;
  &lt;/Project&gt;
  </code></pre>
  
  <p>Why I getting this error:</p>
  
  <blockquote>
    <p>InvalidOperationException: The view 'Components/DataTableComponent/Default.cshtml' was not found. The following locations were searched:
    /Areas/Administration/Views/Customer/Default.cshtml</p>
  </blockquote>
  
  <p>It seems the compiler looking for view in my MVC project instead of the class library project.</p>
  
  <p>Thanks. </p>