AI OnAI Off
Are you using ReSharper? I also get this error, but only when using ReSharper. The only option I'm aware of is to change the error severity — for example the 'Do not show' option will hide the message entirely.
Or in the options menu:
Thank you for the answer, Ynze.
I was able to fix it with a slightly different approach:
Added `ResharperConfig.cs` with the following content:
using JetBrains.Annotations;
[assembly: AspMvcViewLocationFormat("/Features/Shared/{0}.cshtml")]
[assembly: AspMvcViewLocationFormat("/Features/Blocks/{0}.cshtml")]
[assembly: AspMvcViewLocationFormat("/Features/Blocks/{1}/{0}.cshtml")]
[assembly: AspMvcViewLocationFormat("/Features/Shared/Views/{0}.cshtml")]
[assembly: AspMvcViewLocationFormat("/Features/Shared/Views/{1}/{0}.cshtml")]
[assembly: AspMvcViewLocationFormat("/Features/Shared/Views/Header/{0}.cshtml")]
[assembly: AspMvcViewLocationFormat("/Cms/Views/{1}/{0}.cshtml")]
[assembly: AspMvcViewLocationFormat("/Features/{3}/{1}/{0}.cshtml")]
[assembly: AspMvcViewLocationFormat("/Features/{3}/{0}.cshtml")]
[assembly: AspMvcViewLocationFormat("/Features/{3}/{4}/{1}/{0}.cshtml")]
[assembly: AspMvcViewLocationFormat("/Features/{3}/{4}/{0}.cshtml")]
[assembly: AspMvcViewLocationFormat("/Features/Shared/Views/ElementBlocks/{0}.cshtml")]
[assembly: AspMvcAreaPartialViewLocationFormat("/Features/Shared/{0}.cshtml")]
[assembly: AspMvcAreaPartialViewLocationFormat("/Features/Blocks/{0}.cshtml")]
[assembly: AspMvcAreaPartialViewLocationFormat("/Features/Blocks/{1}/{0}.cshtml")]
[assembly: AspMvcAreaPartialViewLocationFormat("/Features/Shared/Views/{0}.cshtml")]
[assembly: AspMvcAreaPartialViewLocationFormat("/Features/Shared/Views/{1}/{0}.cshtml")]
[assembly: AspMvcAreaPartialViewLocationFormat("/Features/Shared/Views/Header/{0}.cshtml")]
[assembly: AspMvcAreaPartialViewLocationFormat("/Cms/Views/{1}/{0}.cshtml")]
[assembly: AspMvcAreaPartialViewLocationFormat("/Features/{3}/{1}/{0}.cshtml")]
[assembly: AspMvcAreaPartialViewLocationFormat("/Features/{3}/{0}.cshtml")]
[assembly: AspMvcAreaPartialViewLocationFormat("/Features/{3}/{4}/{1}/{0}.cshtml")]
[assembly: AspMvcAreaPartialViewLocationFormat("/Features/{3}/{4}/{0}.cshtml")]
[assembly: AspMvcAreaPartialViewLocationFormat("/Features/Shared/Views/ElementBlocks/{0}.cshtml")]
3. Then, I rebuilt the solution
4. ...and restarted Visual Studio.
And... it works fine now :)
When I go to any of the controllers (e.g. HomeController), View is highlighted as red (Visual Studio 2022) saying:
Cannot resolve view 'Index'
Is that because the Features structure is not configured for static analysis?
What's the way to solve it?