System.Web.Mvc가 참조 추가에없는 이유는 무엇입니까?
C #, Visual Studio 2010 사용
MSDN에 문서화 된 System.Web.Mvc 라는 네임 스페이스가 있습니다 . 해당 네임 스페이스의 모든 유형에 대한 설명서에는 해당 유형이 있습니다 System.Web.Mvc.dll
.
그러나 참조 추가,“.NET”탭으로 이동하면이 어셈블리가 목록에서 누락됩니다. 왜?
VS Express 2012에서는 "어셈블리"탭에서 System.Web.Mvc를 찾을 수 없었지만 약간의 검색 후 기본 "어셈블리 \ 프레임 워크"대신 " 어셈블리 \ 확장자 "탭 을 찾아야한다는 것을 알았습니다. " 탭.
가장 좋은 방법은 NuGet 패키지 관리자를 사용하는 것입니다.
아래 MVC 패키지를 업데이트하면 작동합니다.
같은 문제가 발생하여 System.Web.MVC 참조 어셈블리를 찾을 수 없었습니다.
마지막으로 발견하고 다음 위치에 있습니다.
VS가 C :에 설치되어있는 경우 (MVC.dll이 모두가 말하는 기본 위치에 있지 않은 경우 C : 드라이브에 있는 " Reference Assemblies "폴더를 의미합니다 .)
거기에 없다면 분명히 여기에 있어야합니다.
\ 프로그램 파일 (x86) \ Microsoft ASP.NET \ ASP.NET MVC 2 \ Assemblies \ System.Web.Mvc.dll
따라서 참조 추가 메뉴의 탐색 또는 찾아보기 탭을 통해 dll을 추가하십시오.
Nuget 패키지 관리자 콘솔에서 다음과 같이 추가 할 수도 있습니다.
Install-Package Microsoft.AspNet.Mvc -Version 4.0.20710.0 -ProjectName XXXXX
Microsoft.AspNet.Mvc는 다음에 의존합니다.
- '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
.
"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.
Check these step:
- 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.
I solved this problem by searching "mvc". The System.Web.Mvc appeared in search results, despite it is not contained in the list.
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.
일반적으로 2017 인스턴스와 함께 Visual Studio 2015 사본을 설치하면 위의 경로에 필요한 라이브러리가 설치됩니다. 그런 다음 영향을받는 프로젝트의 모든 참조를 업데이트하고 계속 진행합니다.
참고 URL : https://stackoverflow.com/questions/3648364/why-is-system-web-mvc-not-listed-in-add-references
'Programing' 카테고리의 다른 글
ArrayList의 특정 위치에서 요소를 어떻게 업데이트합니까? (0) | 2020.07.03 |
---|---|
문자열에서 처음 3자를 제거 (0) | 2020.07.03 |
ES6 맵 / 세트를 병합하는 가장 간단한 방법은 무엇입니까? (0) | 2020.07.03 |
왜 std :: move std :: shared_ptr을 사용합니까? (0) | 2020.07.03 |
TreeMap을 반복하는 방법? (0) | 2020.07.02 |