Changeset 1107 for trunk/sources/HeuristicLab
- Timestamp:
- 01/09/09 21:29:19 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab/Program.cs
r877 r1107 25 25 using System.Xml; 26 26 using System.Threading; 27 using System.Text; 27 28 using HeuristicLab.PluginInfrastructure; 28 29 … … 31 32 [STAThread] 32 33 static void Main(string[] args) { 33 if (args.Length == 0) { // normal mode 34 Application.EnableVisualStyles(); 35 Application.SetCompatibleTextRenderingDefault(false); 36 Application.Run(new MainForm()); 37 } else if (args.Length == 1) { // start specific application 38 PluginManager.Manager.Initialize(); 39 40 ApplicationInfo app = null; 41 foreach (ApplicationInfo info in PluginManager.Manager.InstalledApplications) { 42 if (info.Name == args[0]) 43 app = info; 44 } 45 if (app == null) { // application not found 46 MessageBox.Show("Cannot start application.\nApplication " + args[0] + " is not installed.\n\nStarting HeuristicLab in normal mode ...", 47 "HeuristicLab", 48 MessageBoxButtons.OK, 49 MessageBoxIcon.Warning); 34 try { 35 if (args.Length == 0) { // normal mode 50 36 Application.EnableVisualStyles(); 51 37 Application.SetCompatibleTextRenderingDefault(false); 52 38 Application.Run(new MainForm()); 53 } else { 54 PluginManager.Manager.Run(app); 39 } else if (args.Length == 1) { // start specific application 40 PluginManager.Manager.Initialize(); 41 42 ApplicationInfo app = null; 43 foreach (ApplicationInfo info in PluginManager.Manager.InstalledApplications) { 44 if (info.Name == args[0]) 45 app = info; 46 } 47 if (app == null) { // application not found 48 MessageBox.Show("Cannot start application.\nApplication " + args[0] + " is not installed.\n\nStarting HeuristicLab in normal mode ...", 49 "HeuristicLab", 50 MessageBoxButtons.OK, 51 MessageBoxIcon.Warning); 52 Application.EnableVisualStyles(); 53 Application.SetCompatibleTextRenderingDefault(false); 54 Application.Run(new MainForm()); 55 } else { 56 PluginManager.Manager.Run(app); 57 } 55 58 } 56 59 } 60 catch (Exception ex) { 61 ShowErrorMessageBox(ex); 62 } 63 } 64 65 public static void ShowErrorMessageBox(Exception ex) { 66 MessageBox.Show(BuildErrorMessage(ex), 67 "Error - " + ex.GetType().Name, 68 MessageBoxButtons.OK, 69 MessageBoxIcon.Error); 70 } 71 72 private static string BuildErrorMessage(Exception ex) { 73 StringBuilder sb = new StringBuilder(); 74 sb.Append("Sorry, but something went wrong!\n\n" + ex.Message + "\n\n" + ex.StackTrace); 75 76 while (ex.InnerException != null) { 77 ex = ex.InnerException; 78 sb.Append("\n\n-----\n\n" + ex.Message + "\n\n" + ex.StackTrace); 79 } 80 return sb.ToString(); 57 81 } 58 82 }
Note: See TracChangeset
for help on using the changeset viewer.