After renaming my MVC project from "SurinderBhomra" to "Site.Web" (to come across less self-serving) I get the following error:
Compiler Error Message: CS0246: The type or namespace name 'xxx' could not be found (are you missing a using directive or an assembly reference?)
But the misleading part of this compiler error is the source file reference to ASP.NET Temporary Files directory, which led me to believe that my build was been cached when it was actually to do with the fact I missed some areas where the old project name still remained.
I carried out a careful rename throughout my project by updating all the places that mattered, such as:
- Using statements
- "AssemblyTitle" and "AssemblyProduct" attributes in AssemblyInfo.cs
- Assembly name and Default Namespace in Project properties (followed by a rebuild)
The key area I missed that caused the above compiler error is overlooking the the namespace section in the /Views/web.config file.
<system.web.webpages.razor> <host factorytype="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=184.108.40.206, Culture=neutral, PublicKeyToken=31BF3856AD364E35"> <pages pagebasetype="System.Web.Mvc.WebViewPage"> <namespaces> ... ... ... <add namespace="System.Web"> ... ... ... </add></namespaces> </pages> </host></system.web.webpages.razor>
When you first create your project in Visual Studio, it automatically adds its original namespace to this file. This also goes for any other web.config you happen to have nested in other areas inside you MVC project.