C# 使用Razor页面在Asp.NET Core 2.2中找不到ViewComponent

C# 使用Razor页面在Asp.NET Core 2.2中找不到ViewComponent,c#,razor,asp.net-core-2.2,asp.net-core-viewcomponent,C#,Razor,Asp.net Core 2.2,Asp.net Core Viewcomponent,我创建了一个非常简单的视图组件(/ViewComponents/MenuViewComponent.cs): 我正在调用\u Layout.cshtml文件中的菜单,如下所示: @await Component.InvokeAsync("MenuViewComponent"); 查看页面时,我收到以下错误消息: InvalidOperationException: A view component named 'MenuViewComponent' could not be found. A

我创建了一个非常简单的视图组件(
/ViewComponents/MenuViewComponent.cs
):

我正在调用
\u Layout.cshtml
文件中的菜单,如下所示:

@await Component.InvokeAsync("MenuViewComponent");
查看页面时,我收到以下错误消息:

InvalidOperationException: A view component named 'MenuViewComponent' 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'.
问题

要使其正常工作,我缺少什么?

请确保组件视图位于搜索路径中,如下所述

参考文献

而且在调用组件时,只需使用不带后缀的名称

@await Component.InvokeAsync("Menu") 

参考确保组件视图位于搜索路径中,并且在调用时只使用不带后缀的名称
@await component.InvokeAsync(“菜单”)
@Nkosi我尝试移动文件以匹配链接中的建议,但没有任何效果。但你的建议只是使用“菜单”来调用,这对我来说是个解决办法。谢谢
InvalidOperationException: A view component named 'MenuViewComponent' 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'.
@await Component.InvokeAsync("Menu")