1. 程式人生 > >由.net framework 3.5切換.net framework 4.5遇到的問題

由.net framework 3.5切換.net framework 4.5遇到的問題

size color none width get inf font 進行 都是

  • 背景

由於server 2012 r2安裝.net framework3.5需要安裝光盤。Scott提出需要把舊項目.net framework升級。不再需要安裝.net framework3.5。舊的系統使用.net framework4的離線安裝包即可,總之避免使用安裝光盤。

所以需要把一個基於.net framework3.5開發的軟件,使用.net framework 4.5重新編譯一次。

原有這個項目是windows xp+VS2008+.net framework開發的。新的項目都使用的WIN7+VS2010+C++進行開發的。所以希望在WIN7上安裝.net 4.5,繼續使用VS2010進行編譯就可以了。

結果遇到了兩個問題或者疑問。

  • 問題1:安裝了.net 4.5,但VS2010無法選擇.net4.5。

技術分享圖片

Stackoverflow有兩個人的回答如下:

  1. Each version of Visual Studio prior to Visual Studio 2010 is tied to a specific .NET framework. (VS2008 is .NET 3.5, VS2005 is .NET 2.0, VS2003 is .NET1.1) Visual Studio 2010 and beyond allow for targeting of prior framework versions but cannot be used for future releases. You must use Visual Studio 2012 in order to utilize .NET 4.5.
  2. You must upgrade to Visual Studio 2012 for .NET v4.5 support.
  3. 另外在百度上看到一張圖片,顯示了visual studio與.net framework之間的關系:

版本

完整版本號

發行日期

Visual Studio

Windows 默認安裝

1.0

1.0.3705.0

2002-02-13

Visual Studio .NET 2002

Windows XP Media Center Edition

Windows XP Tablet PC Edition

1.1

1.1.4322.573

2003-04-24

Visual Studio .NET 2003

Windows Server 2003

2.0

2.0.50727.42

2005-11-07

Visual Studio 2005

3.0

3.0.4506.30

2006-11-06

Windows Vista

Windows Server 2008

3.5

3.5.21022.8

2007-11-19

Visual Studio 2008

Windows 7

Windows Server 2008 R2

4.0

4.0.30319.1

2010-04-12

Visual Studio 2010

4.5Beta

4.5.50501.17626

4.5

4.5.40805

2012-02-20

Visual Studio 2012 RC

Windows 8

Windows Server 2012

4.5.1

4.5.50938.18408

Windows 8.1

Windows Server 2012 R2

4.5.2

4.5.51209.34209

4.6

4.6.00081.00

2015-7-26

Visual Studio 2015

Windows10

4.6.1

4.6.01055.00

Windows10November 2015 Update

4.6.2

4.6.01590.00

4.7

4.7.2053.0

2017-5-2


  • 問題2:為什麽以前基於windows xp +vs2008+.net framework3.5編譯的軟件,無法在自帶.net framework 4的server 2012 r2上運行。.net framework的各個版本之前的兼容性是什麽樣子的?

在CSDN查到一篇類似的文章:https://blog.csdn.net/cnhk1225/article/details/46983209.大意如下:

Net版本之間是有一定聯系的,目前為止微軟推出了3個版本的CLR,分別是 1.1, 2.0 , 4.0 並且你要註意的是 .Net 4是基於CLR4的,而.Net 2.0 3.0 3.5都是基於 CLR2.0, 3.0 3.5其實只是在2.0的基礎上增加了新的功能,並沒有改變CLR。 http://msdn.microsoft.com/zh-cn/library/bb822049.aspx

技術分享圖片

所以,一旦有程序需要CLR2.0環境,你就需要安裝 2.0 3.0 或者 3.5。 建議是安裝3.5, 因為這樣就已經包含了2.0 3.0 的所有內容;而4.0是需要獨立安裝的。

CLR2.0 和 CLR4.0安裝順序沒有要求,所以你只需要一次性安裝一個 .Net 3.5 SP1 和 .Net 4.0 就可以了.

由.net framework 3.5切換.net framework 4.5遇到的問題