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.
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.
Answering so that anyone else has the same issue. There another web.config file under views. please change it there too.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With