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

.NetVisual StudioAssembly References

.Net Problem Overview


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?

.Net Solutions


Solution 1 - .Net

Best way is to use NuGet package manager.

Just update the below MVC package and it should work.

enter image description here

Solution 2 - .Net

In VS Express 2012 I couldn't find System.Web.Mvc in the "assemblies" tab, but after a bit of searching I found out that I need to look into "assemblies\extensions" tab rather than the default "assemblies\framework" tab.

Solution 3 - .Net

I had the same issue and wasn't able to locate the System.Web.MVC reference assembly.

Finally found out and it was located inside the following location.

Note if your VS was installed in C: (Sometimes the MVC.dll is not in the default location which everybody talk about, i mean the "Reference Assemblies" folder located in the C: drive.)

if its not there, it should definitely be in here:

\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 2\Assemblies\System.Web.Mvc.dll

So add the dll through navigating or the browse tab in the add reference menu.

Solution 4 - .Net

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.

Solution 5 - .Net

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.

Solution 6 - .Net

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

Solution 7 - .Net

> "OK, adding that XML to the Web.config > works, but it doesn’t answer the > question"

It should be there. By default the add references list seems to be ordered, but its not the case. Hit the name header and look again.

Solution 8 - .Net

Check these step:

  1. Check MVC is installed properly.
  2. 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.

Solution 9 - .Net

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 FileNewProjectASP.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.

Solution 10 - .Net

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.

Solution 11 - .Net

I didn't get System.Web.Mvc in VS 2012 but I got it in VS 2013. Using AddReference Dialog, enter image description here

Or, You can find this in your project path,

YourProjectName\packages\Microsoft.AspNet.Mvc.5.0.0\lib\net45\System.Web.Mvc.dll

Solution 12 - .Net

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.

Solution 13 - .Net

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

Solution 14 - .Net

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionTimwiView Question on Stackoverflow
Solution 1 - .Netsandeep talabathulaView Answer on Stackoverflow
Solution 2 - .NetjahuView Answer on Stackoverflow
Solution 3 - .Netuser1334789View Answer on Stackoverflow
Solution 4 - .NetfordarehView Answer on Stackoverflow
Solution 5 - .NetAlicanView Answer on Stackoverflow
Solution 6 - .NetzetyView Answer on Stackoverflow
Solution 7 - .NeteglasiusView Answer on Stackoverflow
Solution 8 - .NetImanView Answer on Stackoverflow
Solution 9 - .NetTimwiView Answer on Stackoverflow
Solution 10 - .NetProf Von LemongargleView Answer on Stackoverflow
Solution 11 - .NetMd ShahriarView Answer on Stackoverflow
Solution 12 - .NetBasicView Answer on Stackoverflow
Solution 13 - .Netuser1005462View Answer on Stackoverflow
Solution 14 - .NetJ.D. MallenView Answer on Stackoverflow