Reputation: 38003
I have a ASP.NET MVC 2 project, which references several other projects in my solution. In the C# code, all references work fine, but in the ASP.NET code things go awry - one of the referenced namespaces is not recognized. I put in my Web.config file:
<pages>
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
<add namespace="Project1"/>
<add namespace="Project2"/>
</namespaces>
</pages>
And as soon as I open the project, I get a crash screen with the message:
CS0246: The type or namespace name 'Project2' could not be found (are you missing a using directive or an assembly reference?)
I cannot see anything qualitatively different between Project1
and Project2
, yet the one's namespace is accepted as a valid while the other's isn't. I have explicitly added references to System.Data.Entity
as well; that doesn't seem to help.
Any ideas?
Upvotes: 0
Views: 1591
Reputation: 261
List of things that can be wrong can be found on : http://support.microsoft.com/kb/304656
Short summary
You can also check root namespaces.
Upvotes: 2
Reputation: 6216
That config specifies that the project's namespace should be included in all your pages (equivalent to putting a using statement in all your pages).
It doesn't however add a reference to the project - you probably need to add a reference to one of your other projects. (Project2)
Upvotes: 0