开发者

Why does ASP.NET refuse to recognize the namespace of a related project?

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开发者_JS百科: 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?


List of things that can be wrong can be found on : http://support.microsoft.com/kb/304656

Short summary

  • You might have misspelled the name of the type or namespace that you are trying to use.
  • correct capitalization
  • If the error is a reference to a namespace, you may not have the assembly where the namespace is located referenced in your project.
  • If the error is a reference to a type, then you may not have the proper using directive, or you may have not fully qualified the name of the type.

You can also check root namespaces.


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)


Have you added a reference to Project2?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜