20

I just started a new project and was reorganizing the source structure including renaming namespaces. After changing a namespace from

CRTReadmissions.Web.Helpers

to

Crt.Readmissions.Web.Helpers

I get the error shown below when trying to launch the applicaiton indicating that it can't find the old namespace. Any help is greatly appreciated.

Things I've tried

  1. Clean\Rebuild
  2. Manually delete bin directory
  3. Manually delete the contents of the directory where the generated file is located

Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0246: The type or namespace name 'CRTReadmissions' could not be found (are you missing a using directive or an assembly reference?)

Source Error:

Line 26:     using System.Web.Routing;
Line 27:     using Cassette.Views;
Line 28:     using CRTReadmissions.Web.Constants;
Line 29:     using CRTReadmissions.Web.Helpers;
Line 30:     

Source File: c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\crtreadmission\203bedd5\1b724153\App_Web_login.cshtml.3f4b83a6.wbzlumh4.0.cs Line: 28

Ryan Vice
  • 2,133
  • 3
  • 23
  • 33
  • 2
    Did you previously modify the Web.config in the Views folder to include that old namespace in the pages/namespaces section? – Shawn C. Apr 20 '12 at 18:52

1 Answers1

66

I solved the same problem by editing the web.config file in the Views folder. Just take a look at the namespaces tag. I hope this will help someone who faces the same issue.

Stofkn
  • 1,428
  • 16
  • 24
  • 1
    Thanks for the solution! Even with the new namespace rename tool in Visual Studio 2015 RC, I still ran into this problem with my MVC 5 project. I was getting so frustrated because I did a complete solution search for that old namespace and it never found it in the web.config file. I kept checking my index.cshtml file trying to find the old namespace. – JoeyZero Jul 11 '15 at 06:51
  • Huge help! Thank you! – Steve L. Nov 13 '15 at 16:04
  • I had the same issue (change name space on the project and stuff stop running). Changing web.config in Views folder solved the issue for me as well. – frostshoxx Nov 18 '15 at 17:04
  • 1
    Recreated and deleted temp files and such 3 times figuring it was something I missed. Thank you very much for this comment. – Grandizer Nov 19 '15 at 20:03
  • Such a life saver. I lost so many hours when I renamed my one solution. Thanks – Zapnologica Sep 06 '16 at 07:32
  • You saved my hair a big pulling! That's brilliant, although it's weird it doesn't pop-up as an error in VS. Hope they do something about it! – tfrascaroli Jun 05 '17 at 08:32
  • Emphasis on **in the Views folder**. – chadnt Dec 06 '17 at 20:38
  • thanks, this helped me out big time. – Andie Jan 17 '22 at 10:50