The type or namespace name 'X' does not exist in the namespace 'Y' - in VS generated code

So here is my guess.

In your content.ascx view (or whatever it's named) you have declared:

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<CMSModels.ViewModels.ColourboxViewModel>" %>

instead of

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<CMSModels.ViewModels.ColourBoxViewModel>" %>

I had this error yesterday, and I found these answers, but in my case they didn't help. Instead it turned out that in my client in project properties the Target framework was set to .NET Framework 4 Client Profile. Solution was to change this to full .NET 4. Hope this can help someone, because the error in VS is not very helpfull.

Tags:

C#

Asp.Net Mvc