Why is System.Web.Mvc not listed in Add References

2019-01-21 17:55发布

Using C#, Visual Studio 2010.

There is a namespace called System.Web.Mvc documented on MSDN. The documentation for all the types in that namespace says that they are in System.Web.Mvc.dll.

However, when I go to Add Reference, “.NET” tab, this assembly is missing from the list. Why?

14条回答
Viruses.
2楼-- · 2019-01-21 18:51

You can also add this from the Nuget Package Manager Console, something like:

Install-Package Microsoft.AspNet.Mvc -Version 4.0.20710.0 -ProjectName XXXXX

Microsoft.AspNet.Mvc has dependencies on:

  • 'Microsoft.AspNet.WebPages (≥ 2.0.20710.0 && < 2.1)'
  • 'Microsoft.Web.Infrastructure (≥ 1.0.0.0)'
  • 'Microsoft.AspNet.Razor (≥ 2.0.20710.0 && < 2.1)'

...which seems like no biggie to me. In our case, this is a class library that exists solely to provide support for our Mvc apps. So, we figure it's a benign dependency at worst.

I definitely prefer this to pointing to an assembly on the file system or in the GAC, since updating the package in the future will likely be a lot less painful than experiences I've had with the GAC and file system assembly references in the past.

查看更多
Emotional °昔
3楼-- · 2019-01-21 18:55

I solved this problem by searching "mvc". The System.Web.Mvc appeared in search results, despite it is not contained in the list.

查看更多
登录 后发表回答