Error() public static method

public static Error ( object message ) : void
message object
return void
Beispiel #1
0
 public object CreateObject(string className)
 {
     foreach (Runtime runtime in runtimes)
     {
         object o = runtime.CreateInstance(className);
         if (o != null)
         {
             return(o);
         }
     }
     if (hasShownErrorMessage)
     {
         LoggingService.Error("Cannot create object: " + className);
     }
     else
     {
         hasShownErrorMessage = true;
         MessageService.ShowError("Cannot create object: " + className + "\nFuture missing objects will not cause an error message.");
     }
     return(null);
 }
 public Type FindType(string className)
 {
     LoadDependencies();
     foreach (Runtime runtime in runtimes)
     {
         Type t = runtime.FindType(className);
         if (t != null)
         {
             return(t);
         }
     }
     if (hasShownErrorMessage)
     {
         LoggingService.Error("Cannot find class: " + className);
     }
     else
     {
         hasShownErrorMessage = true;
         MessageService.ShowError("Cannot find class: " + className + "\nFuture missing objects will not cause an error message.");
     }
     return(null);
 }
        /// <summary>
        /// Shows an error.
        /// If <paramref name="ex"/> is null, the message is shown inside
        /// a message box.
        /// Otherwise, the custom error reporter is used to display
        /// the exception error.
        /// </summary>
        public static void ShowError(Exception ex, string message)
        {
            if (message == null)
            {
                message = string.Empty;
            }

            if (ex != null)
            {
                LoggingService.Error(message, ex);
                LoggingService.Warn("Stack trace of last error log:\n" + Environment.StackTrace);
                if (CustomErrorReporter != null)
                {
                    CustomErrorReporter(ex, message);
                    return;
                }
            }
            else
            {
                LoggingService.Error(message);
            }
            ServiceManager.MessageService.ShowError(ex, message);
        }
Beispiel #4
0
        /// <summary>
        /// Loads a list of .addin files, ensuring that dependencies are satisfied.
        /// This method is normally called by <see cref="CoreStartup.RunInitialization"/>.
        /// </summary>
        /// <param name="addInFiles">
        /// The list of .addin file names to load.
        /// </param>
        /// <param name="disabledAddIns">
        /// The list of disabled AddIn identity names.
        /// </param>
        public static void Load(List <string> addInFiles, List <string> disabledAddIns)
        {
            List <AddIn> list = new List <AddIn>();
            Dictionary <string, Version> dict      = new Dictionary <string, Version>();
            Dictionary <string, AddIn>   addInDict = new Dictionary <string, AddIn>();

            foreach (string fileName in addInFiles)
            {
                AddIn addIn;
                try {
                    addIn = AddIn.Load(fileName);
                } catch (AddInLoadException ex) {
                    LoggingService.Error(ex);
                    if (ex.InnerException != null)
                    {
                        MessageService.ShowError("Error loading AddIn " + fileName + ":\n"
                                                 + ex.InnerException.Message);
                    }
                    else
                    {
                        MessageService.ShowError("Error loading AddIn " + fileName + ":\n"
                                                 + ex.Message);
                    }
                    addIn = new AddIn();
                    addIn.addInFileName      = fileName;
                    addIn.CustomErrorMessage = ex.Message;
                }
                if (addIn.Action == AddInAction.CustomError)
                {
                    list.Add(addIn);
                    continue;
                }
                addIn.Enabled = true;
                if (disabledAddIns != null && disabledAddIns.Count > 0)
                {
                    foreach (string name in addIn.Manifest.Identities.Keys)
                    {
                        if (disabledAddIns.Contains(name))
                        {
                            addIn.Enabled = false;
                            break;
                        }
                    }
                }
                if (addIn.Enabled)
                {
                    foreach (KeyValuePair <string, Version> pair in addIn.Manifest.Identities)
                    {
                        if (dict.ContainsKey(pair.Key))
                        {
                            MessageService.ShowError("Name '" + pair.Key + "' is used by " +
                                                     "'" + addInDict[pair.Key].FileName + "' and '" + fileName + "'");
                            addIn.Enabled = false;
                            addIn.Action  = AddInAction.InstalledTwice;
                            break;
                        }
                        else
                        {
                            dict.Add(pair.Key, pair.Value);
                            addInDict.Add(pair.Key, addIn);
                        }
                    }
                }
                list.Add(addIn);
            }
checkDependencies:
            for (int i = 0; i < list.Count; i++)
            {
                AddIn addIn = list[i];
                if (!addIn.Enabled)
                {
                    continue;
                }

                Version versionFound;

                foreach (AddInReference reference in addIn.Manifest.Conflicts)
                {
                    if (reference.Check(dict, out versionFound))
                    {
                        MessageService.ShowError(addIn.Name + " conflicts with " + reference.ToString()
                                                 + " and has been disabled.");
                        DisableAddin(addIn, dict, addInDict);
                        goto checkDependencies;                         // after removing one addin, others could break
                    }
                }
                foreach (AddInReference reference in addIn.Manifest.Dependencies)
                {
                    if (!reference.Check(dict, out versionFound))
                    {
                        if (versionFound != null)
                        {
                            MessageService.ShowError(addIn.Name + " has not been loaded because it requires "
                                                     + reference.ToString() + ", but version "
                                                     + versionFound.ToString() + " is installed.");
                        }
                        else
                        {
                            MessageService.ShowError(addIn.Name + " has not been loaded because it requires "
                                                     + reference.ToString() + ".");
                        }
                        DisableAddin(addIn, dict, addInDict);
                        goto checkDependencies;                         // after removing one addin, others could break
                    }
                }
            }
            foreach (AddIn addIn in list)
            {
                try {
                    InsertAddIn(addIn);
                } catch (AddInLoadException ex) {
                    LoggingService.Error(ex);
                    MessageService.ShowError("Error loading AddIn " + addIn.FileName + ":\n"
                                             + ex.Message);
                }
            }
        }
Beispiel #5
0
 /// <summary>
 /// Shows an exception.
 /// </summary>
 public static void ShowException(Exception ex, string message)
 {
     LoggingService.Error(message, ex);
     LoggingService.Warn("Stack trace of last exception log:\n" + Environment.StackTrace);
     ServiceManager.Instance.MessageService.ShowException(ex, message);
 }
Beispiel #6
0
 /// <summary>
 /// Shows an error using a message box.
 /// </summary>
 public static void ShowError(string message)
 {
     LoggingService.Error(message);
     ServiceManager.Instance.MessageService.ShowError(message);
 }