ASP.Net MVC3安全升級導致程式集從3.0.0.0變為3.0.0.1

來源:互聯網
上載者:User

標籤:mvc

一直以來,開發MVC3應用,在部署的時候為了方便,並不在使用者環境安裝MVC3,只是把用到的幾個assembly直接部署到bin裡,包括:

  • Microsoft.Web.Infrastructure.dll

  • System.Web.Helpers.dll

  • System.Web.MVC.dll

  • System.Web.WebPages.Deployment.dll

  • System.Web.WebPages.dll

  • System.Web.WebPages.Razor.dll


最近系統升級,再這麼部署網站時,發現不好用了,報錯:

Compiler Error Message: CS1705: 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版去。再訪問網站,一切正常了。



本文出自 “兔子窩” 部落格,請務必保留此出處http://boytnt.blog.51cto.com/966121/1590928

ASP.Net MVC3安全升級導致程式集從3.0.0.0變為3.0.0.1

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.