Windows 업데이트 후“ 'System.Web.Mvc'네임 스페이스에 'Html'유형 또는 네임 스페이스 이름이 없습니다.”
Windows 업데이트를 수행 한 후 asp.net mvc 5 응용 프로그램이 더 이상 불평을로드하지 않습니다.
CS0234: The type or namespace name 'Html' does not exist in the namespace 'System.Web.Mvc'
내 뷰 web.config가 잘못되었음을 나타냅니다.
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Optimization"/>
<add namespace="System.Web.Routing" />
<add namespace="Ogre.Extensions" />
<add namespace="Newtonsoft.Json"/>
</namespaces>
</pages>
</system.web.webPages.razor>
이제 이것은 매우 혼란 스럽습니다. 내 프로젝트 자체에서 Html네임 스페이스를 볼 수 있고 , ILSpy에서 어셈블리를 열 수 있습니다. 바운드로 이동할 System.Web.Mvc수도 있고이를 수행 할 수도 있습니다. 퓨전 로그에는 의심스러운 바인딩 오류가 표시되지 않습니다.
그것은 것처럼입니다 단지 내 의견은 MVC의 이전 버전에 (성공적으로) 결합 얻고있다. 왜 그렇게 될까요? 어떻게 고칠 수 있습니까?
구성이나 코드 변경이 없었 음을 분명히하겠습니다. 이것은 IISExpress의 내 dev 컴퓨터에 있습니다. 실행 중이었고 업데이트를 수행하고 재부팅했으며 이제 더 이상 실행되지 않습니다.
다음은 업데이트로 인한 최근 설치입니다. 하나씩 제거 할 수는 있지만 이야기의 일부가 누락 된 것처럼 느껴져 실제로 무엇이 잘못되고 있는지 알고 싶습니다.

힌트를 준 @ Nevada-Williford에게 감사합니다. 들어가서 내 System.Web.Mvc참조를 <Private>True</Private>(Copy Local = True)로 설정하여 수정했습니다. 업데이트 전에 모든 것이 작동하고 업데이트 후 다시 작동하도록 csproj를 수정해야했습니다.
무슨 일이 일어나고 있는지에 대한 작업 이론 :
Copy Local = True그리고 <Private>True</Private>거의로 사용, 하지만 정확히 같은 일. 전자는 Visual Studio 설정이고 후자는 msbuild 설정입니다. msbuild 설정이 없으면 Visual Studio 설정이 적용됩니다 (VS에있는 한). 이 업데이트에서 나는 그들이 그것을 변경했다고 생각하므로 Copy Local존재 속성을 반영합니다.
우리 프로젝트에서는 해당 속성이 명시 적으로 설정되어 있지 않지만 Copy Local = True업데이트 전에 System.Web.Mvc.dllbin 디렉토리에 복사됩니다. 업데이트 후, 속성 때문에없는 Copy Local쇼를 False하고 당신은 그것을 설정해야 True당신이 로컬 복사본을 얻을 수 있도록.
수동으로 설정 Copy Local = True(또는 해당 xml 요소를 msbuild에 추가)하면 문제가 해결됩니다.
편집 : 이것이 특정 질문에 대한 답인 것처럼 보이지만 여기에 오는 사람은 더 많은 컨텍스트, 경고 및 관련 버그에 대해 주석 스레드 및 기타 답변 (특히 dmatson의 답변)을 읽어야합니다.
이것은 MS14-059에 의해 CopyLocal=true(또는 MSBuild에서 말하는 <Private>True</Private>) 모든 사용자에게 손상되었습니다 . MVC 템플릿은 기본적으로 설정 되지만 NuGet을 사용하여 MVC 버전을 업데이트하면 해당 설정이 손실됩니다 ( NuGet 버그 # 4344 참조 ).<Private>True</Private>
문제에는 두 가지 측면이 있습니다.
- Razor는 기본적으로 MVC에 대한 참조를 포함하지 않으므로 일부 버전의 MVC DLL이 bin 폴더에 있지 않으면 컴파일이 작동하지 않습니다.
- 이 업데이트가 설치되지 않은 별도의 컴퓨터에 배포하는 경우 MVC DLL이 더 이상 출력에 포함되지 않으므로 MVC가 누락됩니다.
문제 # 1이 표시됩니다. 두 가지 문제를 모두 해결하려면 다음과 같이 변경하는 것이 좋습니다.
다음 구성을 Views \ Web.config에 추가합니다.
<system.web> <compilation> <assemblies> <add assembly="System.Web.Mvc, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> </assemblies> </compilation> </system.web>CopyLocal=true프로젝트 참조를 위해 VS UI에서 설정 하거나Reference.csproj 파일에서 아래의 다음 줄을 수동으로 추가 합니다.<Private>True</Private>
따라서 전체 참조는 다음과 같아야합니다.
<Reference Include="System.Web.Mvc, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<Private>True</Private>
<HintPath>..\..\packages\Microsoft.AspNet.Mvc.5.0.0\lib\net45\System.Web.Mvc.dll</HintPath>
</Reference>
Note that NuGet will remove the CopyLocal/Private setting if you update packages again in the future. (For example, if you update to MVC 5.2 today). If that version of MVC is ever GAC'd, problem #1 above will not recur as long as you've added the configuration in step A above, but problem #2 could still happen again. To ensure this doesn't happen in the future, I'd recommend manually setting CopyLocal back to true any time you do a NuGet package update.
- You can go to References of current Project.
- Right click in dll
System.Web.Mvcand choose Properties - A Properties window will open
- Change Copy Local to
True
Setting CopyLocal=true did not help. Cleaning the solution then closing it and reopening it again worked. You might need to close the entire Visual Studio instance as well.
This appears to have been caused by a Windows Update (KB2990942) to fix security vulnerablity MS14-059, allowing security feature bypass. Our builds stopped working on our build server after the Windows Update was installed, and updating the csproj files to use 4.0.0.1 for the System.Web.Mvc reference fixed the issue.
Microsoft's description of the vulnerability is:
The vulnerability could allow security feature bypass if an attacker convinces a user to click a specially crafted link or to visit a webpage that contains specially crafted content designed to exploit the vulnerability. In a web-based attack scenario, an attacker could host a specially crafted website that is designed to exploit the vulnerability through a web browser, and then convince a user to view the website. The attacker could also take advantage of compromised websites and websites that accept or host user-provided content or advertisements. These websites could contain specially crafted content that could exploit the vulnerability. In all cases, however, an attacker would have no way to force users to view the attacker-controlled content. Instead, an attacker would have to convince users to take action, typically by getting them to click a link in an email message or in an Instant Messenger message that takes them to the attacker's website, or by getting them to open an attachment sent through email.
As well as setting CopyLocal=true in the project reference you may also need to change the Web.Config file like so...
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.1" />
</dependentAssembly>
Notice the newVersion="4.0.0.1". This worked for me, and I hope it helps a few people out as well.
Saves updating the MVC framework on any test/production servers.
Cheers Microsoft. You're the best!
Your attempt to make me look incompetent in front of my clients has been foiled yet again!
As well as setting CopyLocal=true in the project reference you may also need to change the Web.Config file like so...
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.1" />
</dependentAssembly>
I added culture="neutral" also, and all this solved the problem.
'program story' 카테고리의 다른 글
| 각 매개 변수에서 후행 슬래시를 제거하는 가장 간단한 방법은 무엇입니까? (0) | 2020.11.13 |
|---|---|
| 이 var 문자열을 신속하게 NSURL로 변환하는 방법 (0) | 2020.11.13 |
| .NET에서 디렉토리 크기를 계산하는 가장 좋은 방법은 무엇입니까? (0) | 2020.11.13 |
| Entity Framework 엔터티 연결을 사용하는 경우 MetadataException (0) | 2020.11.13 |
| java.security.Signature 대 MessageDigest 및 Cipher와 함께 SHA1 및 RSA 사용 (0) | 2020.11.12 |