usr*_*usr 107 .net versioning asp.net-mvc assembly-references assembly-binding-redirect
安装ASP.NET MVC 3安全更新后KB2990942,MVC版本似乎从3.0.0.0增加到3.0.0.1.这会导致Visual Studio不再找到引用.
<Reference Include="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
Run Code Online (Sandbox Code Playgroud)
Resharper没有显示任何问题,但构建失败,有许多未解析的MVC类型和警告:
警告:无法解析此引用.无法找到程序集"System.Web.Mvc,Version = 3.0.0.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35,processorArchitecture = MSIL".检查以确保磁盘上存在程序集.如果您的代码需要此引用,则可能会出现编译错误.
这种做法很有道理.我的机器上不再存在此版本.
我无法保证dev机器,构建服务器和生产服务器上的确切MVC版本.他们可能有3.0.0.0或3.0.0.1可能随时改变.Windows Update可能随时发布新的MVC版本.此外,每当发布MVC更新时,我都不希望增加所有*.csproj文件中的版本号.
更新会影响多个版本:
安全公告:MS14-059:ASP.NET MVC中的漏洞可能允许安全功能绕过(2990942)
处理这种情况的最佳方法是什么?如何在未来的MVC更新中展开构建和生产并保持安全?
Guf*_*ffa 66
我解决了这个问题:
Copy Local引用的属性更改为true.bindingRedirect设置web.config:web.config runtime部分:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.1" />
</dependentAssembly>
...
Run Code Online (Sandbox Code Playgroud)
更改Copy Local设置将System.Web.MVC.dll在bin发布项目时将文件包含在文件夹中,这样即使服务器未使用新版本更新,它也能正常工作.
请注意,这样的更新很少发生.这是MVC 3自发布以来第一次被修补.一旦服务器更新,您应该能够更改Copy Local回false.下次微软发布这样的更新时,他们可能会知道首先解决这样的问题.
gun*_*erz 27
我使用Nuget在我的项目中安装了Microsoft.AspNet.Mvc包.
Install-Package Microsoft.AspNet.Mvc -Version <version> -Project PROJECTNAME
MVC 4 version: 4.0.40804.0
MVC 3 version: 3.0.50813.1
Run Code Online (Sandbox Code Playgroud)
这解决了这个问题.详情请访问:http: //blogs.msdn.com/b/webdev/archive/2014/10/16/microsoft-asp-net-mvc-security-update-broke-my-build.aspx
Dav*_*tin 12
您的生产系统应该没问题,因为此修补程序将配置文件(System.Web.Mvc.dll.config)传递到以下文件夹:
%SystemRoot%\assembly\GAC_MSIL\policy.3.0.System.Web.Mvc\3.0.0.1__31bf3856ad364e35
Run Code Online (Sandbox Code Playgroud)
配置文件包含重定向到新版本的程序集,这将覆盖web.config中的任何内容:
<?xml version="1.0"?>
<!-- http://msdn.microsoft.com/en-us/library/7wd6ex19.aspx#BKMK_Redirectingassemblyversionsbyusingpublisherpolicy -->
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="3.0.0.0-3.0.0.1" newVersion="3.0.0.1"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
Run Code Online (Sandbox Code Playgroud)
遵循@Guffa对构建系统的建议,或使用nuget进行更新.我认为有效的解决方案取决于您如何将MVC二进制文件传送到您的系统(bin部署或GAC).
| 归档时间: |
|
| 查看次数: |
45717 次 |
| 最近记录: |