Как получить версию .NET Framework
Материал из 1GbWiki.
(Различия между версиями)
Текущая версия
[править] Вот так
<%@ Import Namespace="System.Reflection" %> <%@ Page Language="C#" %> <% // Unique framework assembly string fw30assembly = "PresentationCore, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"; string fw35assembly = "System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"; string fw35sp1assembly = "System.Data.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"; Version frameworkVersion = Environment.Version; string frameworkUpdate = ""; if (frameworkVersion.Major == 2) { try { // try load 3.0 assembly... frameworkVersion = AssemblyName.GetAssemblyName(Assembly.Load(fw30assembly).Location).Version; // ... 3.5 frameworkVersion = AssemblyName.GetAssemblyName(Assembly.Load(fw35assembly).Location).Version; // ... 3.5 sp1 frameworkVersion = AssemblyName.GetAssemblyName(Assembly.Load(fw35sp1assembly).Location).Version; frameworkUpdate = "SP1"; } catch { // Assembly load filed } } string ver = string.Format(".NET Framework version is {0}.{1} {2}", frameworkVersion.Major, frameworkVersion.Minor, frameworkUpdate); Response.Write(ver); %>