Eliad
Eliad

Reputation: 39

ASP.NET RAZOR The type or namespace name does not exist in the namespace (but it exists)

Im trying to use an object called DBUser (which located in the namespace DevicesHub.DAL.DBClasses) in cshtml page.

In the same solutions I have the projects DevicesHub.DAL and DevicesHub.WebApplication.

Before running the web application it won't show any problem: I can't see where is the problem

In the project DevicesHub.DAL I have a namespace called DevicesHub.DAL.DBClass.

This is the problem I have: View problem

  • So in order to fix it I tryed adding reference from DevicesHub.DAL to the DevicesHub.WebApplication project.

  • In addition I tryed to adding the reference to the app.config file:

<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="System.Web.Routing" />
    <add namespace="DevicesHub.DAL.DBClasses" />

  </namespaces>
  • I tryed to remove the obj folder, the temp folder, clean the project and the solution.

  • Also, I tryed to change all the projects' .net versions.

  • Nothing helped and I stack with this problem for hours.

Upvotes: 1

Views: 1072

Answers (1)

Eliad
Eliad

Reputation: 39

Ok, I have fixed It . I found that I can add another project as a reference to the website.

So, I copied the project and created the project that didn't work again.

I have no idea why but that fixed it.

Upvotes: 1

Related Questions