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.
–
I have had the same problem and here is the funny reason: My guess is that you expect System.Web.Mvc
to be located under System.Web
in the list. But the list is not alphabetical.
First sort the list and then look near the System.Web
.
–
–
–
–
Check MVC is installed properly.
Check the project's property and see what is the project Target Framework. If the target framework is not set to .Net Framework 4, set it.
Note: if target framework is set to .Net Framework 4 Client Profile, it will not list MVC reference on references list. You can find different between .Net Framework 4 and .Net Framework 4 Client Profile here.
The .NET Framework 4 Client Profile is a subset of the .NET Framework 4 that is optimized for client applications. It provides functionality for most client applications, including Windows Presentation Foundation (WPF), Windows Forms, Windows Communication Foundation (WCF), and ClickOnce features. This enables faster deployment and a smaller install package for applications that target the .NET Framework 4 Client Profile.
–
The desired assembly has appeared in the list now.
I can only speculate what caused it to appear, but I suspect it is the fact that I went File → New → Project → ASP.NET Web Application, which I had never done before. It is possible that this caused some sort of late initialisation to happen and the list to be populated with additional assemblies for Web development.
–
–
–
This has changed for Visual Studio 2012 (I know the original question says VS2010, but the title will still hit on searches).
When you create a VS2012 MVC project, the system.web.mvc is placed in the packages folder which is peer to the solution. This will be referenced in the web project by default and you can find the exact path there).
If you want to reference this in a secondary project (say a supporting .dll with filters or other attributes), then you can reference it from there.
I didn't get System.Web.Mvc in VS 2012 but I got it in VS 2013.
Using AddReference Dialog,
Or, You can find this in your project path,
YourProjectName\packages\Microsoft.AspNet.Mvc.5.0.0\lib\net45\System.Web.Mvc.dll
I believe you'll find the MVC assembly is referenced in the web.config file, not in the project itself.
Something like this:
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</assemblies>
</compilation>
To respond to your comment;
The best answer I can give is from here:
The add element adds an assembly
reference to use during compilation of
a dynamic resource. ASP.NET
automatically links this assembly to
the resource when compiling each code
module.
it can be installed separated,
and it's not included in framwork,
choose tab list "extensions" and it exists there are and more other libs,
all is ok not needed to used old libs etc,
exists old 20 30 and 4001
If you got this problem in Visual Studio 2017, chances are you're working with an MVC 4 project created in a previous version of VS with a reference hint path pointing to C:\Program Files (x86)\Microsoft ASP.NET
. Visual Studio 2017 does not install this directory anymore.
We usually solve this by installing a copy of Visual Studio 2015 alongside our 2017 instance, and that installs the necessary libraries in the above path. Then we update all the references in the affected projects and we're good to go.