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'."


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.





Jack (Developer) said:

Is this error happening on the Front-End Stack?

Posted On: December 04, 2021 20:05:13 PM


For peering opportunity Autonomouse System Number: AS401345 Custom Software Development at ErnesTech Email AddressContact: [email protected]