2016年7月27日 星期三

VS2013 MVC 5專案升級VS2015

 

Tool:Visual Studio 2015 Ultimate Update 3
OS:Windows 10
.NET Framework : 4.6.x

將VS 2013 MVC專案,拿到VS2015的環境開起來,雖然程式可以正確編譯,但執行網站產生錯誤,訊息:

 

Could not load file or assembly 'Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

image

檢視packages.config,似乎也沒有記錄有安裝'Microsoft.Web.Infrastructure’套件:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="EntityFramework" version="6.0.1" targetFramework="net451" />
  <package id="Microsoft.AspNet.Mvc" version="5.0.0" targetFramework="net451" />
  <package id="Microsoft.AspNet.Razor" version="3.0.0" targetFramework="net451" />
  <package id="Microsoft.AspNet.WebApi" version="5.2.3" targetFramework="net451" />
  <package id="Microsoft.AspNet.WebApi.Client" version="5.2.3" targetFramework="net451" />
  <package id="Microsoft.AspNet.WebApi.Core" version="5.2.3" targetFramework="net451" />
  <package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.3" targetFramework="net451" />
  <package id="Microsoft.AspNet.WebPages" version="3.0.0" targetFramework="net451" />
  <package id="Newtonsoft.Json" version="6.0.8" targetFramework="net451" />
</packages>

解法,使用Package Manager Console重新安裝'Microsoft.Web.Infrastructure'

 

Install-Package Microsoft.Web.Infrastructure

完成後網站就可以順利執行

檢視packages.config,MVC的版本並沒有隨之升級成新版

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="EntityFramework" version="6.0.1" targetFramework="net451" />
  <package id="Microsoft.AspNet.Mvc" version="5.0.0" targetFramework="net451" />
  <package id="Microsoft.AspNet.Razor" version="3.0.0" targetFramework="net451" />
  <package id="Microsoft.AspNet.WebApi" version="5.2.3" targetFramework="net451" />
  <package id="Microsoft.AspNet.WebApi.Client" version="5.2.3" targetFramework="net451" />
  <package id="Microsoft.AspNet.WebApi.Core" version="5.2.3" targetFramework="net451" />
  <package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.3" targetFramework="net451" />
  <package id="Microsoft.AspNet.WebPages" version="3.0.0" targetFramework="net451" />
  <package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net461" />
  <package id="Newtonsoft.Json" version="6.0.8" targetFramework="net451" />
</packages>

 

這時可以使用Package Manager Console更新所有套件為新版

update-package -Reinstall

這樣就完成升級做業了。packages.config:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="EntityFramework" version="6.0.1" targetFramework="net461" />
  <package id="Microsoft.AspNet.Mvc" version="5.0.0" targetFramework="net461" />
  <package id="Microsoft.AspNet.Razor" version="3.0.0" targetFramework="net461" />
  <package id="Microsoft.AspNet.WebApi" version="5.2.3" targetFramework="net461" />
  <package id="Microsoft.AspNet.WebApi.Client" version="5.2.3" targetFramework="net461" />
  <package id="Microsoft.AspNet.WebApi.Core" version="5.2.3" targetFramework="net461" />
  <package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.3" targetFramework="net461" />
  <package id="Microsoft.AspNet.WebPages" version="3.0.0" targetFramework="net461" />
  <package id="Newtonsoft.Json" version="6.0.8" targetFramework="net461" />
</packages>

沒有留言:

總網頁瀏覽量