Free cookie consent management tool by TermsFeed Policy Generator

source: branches/RemoveBackwardsCompatibility/HeuristicLab.PluginInfrastructure/3.3/ErrorHandling/FrameworkVersionErrorDialog.cs @ 15428

Last change on this file since 15428 was 12012, checked in by ascheibe, 10 years ago

#2212 merged r12008, r12009, r12010 back into trunk

File size: 3.8 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10   * (at your option) any later version.
11   *
12   * HeuristicLab is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15   * GNU General Public License for more details.
16   *
17   * You should have received a copy of the GNU General Public License
18   * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19   */
20#endregion
21
22using System;
23using System.Reflection;
24using System.Windows.Forms;
25
26namespace HeuristicLab.PluginInfrastructure {
27  public partial class FrameworkVersionErrorDialog : Form {
28    private const string NETVersionPath = @"Software\Microsoft\NET Framework Setup\NDP\v4\Full";
29    private const string NETVersion = "Version";
30
31    public static bool NET4_5Installed {
32      get {
33        try {
34          var registryKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(NETVersionPath);
35          if (registryKey != null) {
36            var versionKey = registryKey.GetValue(NETVersion);
37            if (versionKey != null) {
38              Version version = new Version(versionKey.ToString());
39              return version.Major >= 4 && version.Minor >= 5;
40            }
41          }
42        }
43        catch (System.Security.SecurityException) {
44          return false;
45        }
46        return false;
47      }
48    }
49
50    public static bool MonoInstalled {
51      get { return Type.GetType("Mono.Runtime") != null; }
52    }
53
54    public static bool MonoCorrectVersionInstalled {
55      get {
56        var monoVersion = MonoVersion;
57        var minRequiredVersion = new Version(3, 6, 0);
58
59        //we need at least mono version 3.6.0
60        if (monoVersion != null && monoVersion >= minRequiredVersion) {
61          return true;
62        } else {
63          return false;
64        }
65      }
66    }
67
68    public static Version MonoVersion {
69      get {
70        Type type = Type.GetType("Mono.Runtime");
71        if (type != null) {
72          MethodInfo dispalayName = type.GetMethod("GetDisplayName", BindingFlags.NonPublic | BindingFlags.Static);
73          if (dispalayName != null) {
74            string versionString = dispalayName.Invoke(null, null) as string;
75            if (versionString != null) {
76              // the version string looks something like: 2.11.4 (master/99d5e54 Thu Sep  6 15:55:44 CEST 2012)
77              var subVerStrings = versionString.Split(' ');
78              if (subVerStrings.Length > 0) {
79                try {
80                  return Version.Parse(subVerStrings[0]);
81                }
82                catch { }
83              }
84            }
85          }
86        }
87        return null;
88      }
89    }
90
91    public FrameworkVersionErrorDialog() {
92      InitializeComponent();
93    }
94
95    private void linkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) {
96      try {
97        System.Diagnostics.Process.Start("http://www.microsoft.com/en-us/download/details.aspx?id=30653");
98        linkLabel.LinkVisited = true;
99      }
100      catch (Exception) { }
101    }
102
103    private void cancelButton_Click(object sender, EventArgs e) {
104      Application.Exit();
105    }
106
107    private void linkLabelMono_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) {
108      try {
109        System.Diagnostics.Process.Start("http://www.mono-project.org");
110        linkLabelMono.LinkVisited = true;
111      }
112      catch (Exception) { }
113    }
114  }
115}
Note: See TracBrowser for help on using the repository browser.