Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ERROR AFTER CHANGING NAMESPACE OF ASP.net MVC PROJECT

Tags:

namespaces

Recently i have changed the namespace using the project properties. After that, application was compiling successfully, but at run-time it throws error "The type or namespace name ‘sample’ could not be found (are you missing a using directive or an assembly reference?)". Error: Line 23: using System.Web.Routing; Line 24: using Sample;

Source File: c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files......\App_Web_index.cs Line:

I tried to locate the string “using Sample” and didn’t find anywhere in my solution. Tried removing the temporary files from framework folder but no luck.

like image 987
Sree Avatar asked Dec 06 '25 08:12

Sree


2 Answers

The problem was with my Web.config file

<system.web.webPages.razor>
 <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
 <pages pageBaseType="System.Web.Mvc.WebViewPage">
  <namespaces>
    <add namespace="System.Web.Mvc" />
    <add namespace="System.Web.Mvc.Ajax" />
    <add namespace="System.Web.Mvc.Html" />
    <add namespace="System.Web.Optimization"/>
    <add namespace="System.Web.Routing" />
    <add namespace="Sample" />
  </namespaces>
</pages>

I just replaced the old value "Sample" with new namespace name, and everything starts working again.

like image 75
Sree Avatar answered Dec 12 '25 13:12

Sree


Answering so that anyone else has the same issue. There another web.config file under views. please change it there too.

like image 31
Shashikanth Hosur Avatar answered Dec 12 '25 14:12

Shashikanth Hosur



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!