InvalidOperationException: A view component named 'NameHere' 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'

Question: I have looked and looked for this error and could not find where the problem is located. "InvalidOperationException: A view component named 'NameHere' 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'."


Please Login to see the rest of the answer

Answer: Keep looking, verify the following,

1. Verify that the class driving the View Component is spelled correctly
    e.g. NameOfYourComponetViewComponent
  - Keep in mind that you should be looking for the misspelling of Component, it could be that it is missing an 'n'.

2. Verify that the ViewComponent has a corresponding Folder in the Shared/Component Folder. The Folder containing the View Component Default File should be of the same Name as the ViewComponent Class but without the "ViewComponent" attribute or section of the name. 

For Example, if the View Component class is named MyClassViewComponent then the Folder containing the Default file should be named "MyClass" in order for the compiler to find the corresponding Default file.

3. If you still have problems, stop debugging, clean the Solution and Build your project. Some dependency might be lagging and would need a clean and a build in order to recompile.

Let me know if this helps you in the comments below.


Write an Article
If you log in, you will be notified when someone leaves a comment.

Other users would like to know if this solution helped you.

Jack (Developer) said:

Is this error happening on the Front-End Stack?


© 2022 - ErnesTech - Privacy