public AddinLoadErrorDialog(AddinError[] errors) { XML glade = new XML (null, "MonoDevelop.Startup.glade", "addinLoadErrorDialog", null); glade.Autoconnect (this); TreeStore store = new TreeStore (typeof(string)); errorTree.AppendColumn ("Addin", new CellRendererText (), "text", 0); errorTree.Model = store; bool fatal = false; foreach (AddinError err in errors) { string name = Path.GetFileNameWithoutExtension (err.AddinFile); if (err.Fatal) name += " (Fatal error)"; TreeIter it = store.AppendValues (name); store.AppendValues (it, "Full Path: " + err.AddinFile); store.AppendValues (it, "Error: " + err.Exception.Message); it = store.AppendValues (it, "Exception: " + err.Exception.GetType ()); store.AppendValues (it, err.Exception.StackTrace.ToString ()); if (err.Fatal) fatal = true; } // addinLoadErrorDialog.ShowAll (); if (fatal) { noButton.Hide (); yesButton.Hide (); labelContinue.Hide (); closeButton.Show (); labelFatal.Show (); } }
public static AddinError[] InitializeAddins() { AssemblyLoader loader = new AssemblyLoader(); try { loader.CheckAssembly (Assembly.GetEntryAssembly ()); } catch (Exception ex) { AddinError err = new AddinError (Assembly.GetEntryAssembly ().Location, ex, true); return new AddinError[] { err }; } AddinError[] errors = null; addInTree = new DefaultAddInTree (loader); FileUtilityService fileUtilityService = (FileUtilityService)ServiceManager.GetService(typeof(FileUtilityService)); StringCollection addInFiles = null; StringCollection retryList = null; if (ignoreDefaultCoreDirectory == false) { addInFiles = fileUtilityService.SearchDirectory(defaultCoreDirectory, "*.addin.xml"); retryList = InsertAddIns (addInFiles, out errors); } else retryList = new StringCollection(); if (addInDirectories != null) { foreach(string path in addInDirectories) { addInFiles = fileUtilityService.SearchDirectory(path, "*.addin.xml"); StringCollection partialRetryList = InsertAddIns (addInFiles, out errors); if (partialRetryList.Count != 0) { string [] retryListArray = new string[partialRetryList.Count]; partialRetryList.CopyTo(retryListArray, 0); retryList.AddRange(retryListArray); } } } while (retryList.Count > 0) { StringCollection newRetryList = InsertAddIns (retryList, out errors); // break if no add-in could be inserted. if (newRetryList.Count == retryList.Count) { break; } retryList = newRetryList; } return errors; }
static StringCollection InsertAddIns(StringCollection addInFiles, out AddinError[] errors) { StringCollection retryList = new StringCollection(); ArrayList list = new ArrayList (); foreach (string addInFile in addInFiles) { AddIn addIn = new AddIn(); try { addIn.Initialize (addInFile); addInTree.InsertAddIn (addIn); } catch (CodonNotFoundException ex) { retryList.Add (addInFile); list.Add (new AddinError (addInFile, ex, false)); } catch (ConditionNotFoundException ex) { retryList.Add (addInFile); list.Add (new AddinError (addInFile, ex, false)); } catch (MissingDependencyException ex) { // Try to load the addin later. Maybe it depends on an // addin that has not yet been loaded. retryList.Add(addInFile); list.Add (new AddinError (addInFile, ex, false)); } catch (InvalidAssemblyVersionException ex) { retryList.Add (addInFile); list.Add (new AddinError (addInFile, ex, false)); } catch (Exception ex) { retryList.Add (addInFile); list.Add (new AddinError (addInFile, ex, false)); } } errors = (AddinError[]) list.ToArray (typeof(AddinError)); return retryList; }