码迷,mamicode.com
首页 > Web开发 > 详细

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

时间:2015-08-28 17:31:26      阅读:166      评论:0      收藏:0      [点我收藏+]

标签:

开发环境一般引用的是本机 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版去。再访问站点,一切正常了。

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

标签:

原文地址:http://www.cnblogs.com/tyhj-zxp/p/4766790.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!