ASP.Net MVC3安全升级导致程序集从3.0.0.0变为3.0.0.1

开发环境一般引用的是本机 C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 3\Assemblies下的System.Web.Mvc.dll,当系统更新时,此文件会更新为高级版本,从而和已经部署到服务器上的System.Web.Mvc.dll版本不一致。从能在线上运行时报下面的错误:

Assembly 'TestUnsafe, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' uses 'System.Web.Mvc, Version=3.0.0.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35' which has a higher version than referenced assembly 'System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'

发现没?System.Web.MVC的版本要求是3.0.0.1,而bin里放的仍然是3.0.0.0,肯定跑不起来。

OK,换个新的程序集上去,把System.Web.MVC.dll 3.0.0.1版放上去,仍然跑不起来,报错:

Parser Error Message: Could not load file or assembly 'System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

 

这是由于Web.config未更新导致的,找到下面的几行:

  <runtime>    

 <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">       <dependentAssembly>         <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />         <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0" />       </dependentAssembly>  

</assemblyBinding>

  </runtime>

 

调整oldVersion和newVersion,改成:

  <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>     </assemblyBinding>   </runtime>

 

看到没?把旧版本的MVC统一映射到3.0.0.1版去。再访问站点,一切正常了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值