3

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.

2 Answers 2

10

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.

Sign up to request clarification or add additional context in comments.

1 Comment

this may work at first, but somehow (the next times or sometimes) the old value is still cached somewhere and VS (Intelligently) uses that cached value, cannot stand this bug.
3

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.