I am trying to work through this tutorial, (ASP.Net Core Razor Pages) but (often) when I build the solution, I get a CS0234 error stating that a namespace is missing from file 'Index.g.cshtml.cd'...….but where does this file exist? I have tried 1. All the build/clean/rebuild solution options. 2. I have restarted Visual Studio 3. I have deleted the DEBUG files and restarted VS and FINALLY 4. I have restarted my PC. The ONLY solution that seems to work, is to delete the entire solution/project and start again.
Surely there must be a fix for this? Can you assist?
Recently I have faced the same issue,
Try the following simple method
copy the error and paste it in the notepad. There you can able to see the original root cause path of the error file, e.g
'YourProjectFolder'\obj\Debug\netcoreapp2.2\Razor\Views\'View Name'\index.g.cshtml.cs
Locate the file, if the error really persists refer the correct namespace in your index.cshtml file else delete the file and rebuild.
Also check you have any duplicate file and which was excluded from the project. If it is exists delete the file too
Now clean and rebuild the project. (You may need to clean, close VS, rebuild)
Try to clean all the obj folders in all of your projects and build again. This is part of the code that is generated by the compiler, sometimes it is not synchronized with the view itself, even Rebuild that should clean everything doesn't work. Do it manually. Hope this helps