Ejemplo n.º 1
0
 public void FireConfigurationFailureEvent(System.Configuration.ConfigurationErrorsException configurationException)
 {
     if (configurationFailure != null)
     {
         configurationFailure(this, new LoggingConfigurationFailureEventArgs(configurationException));
     }
 }
Ejemplo n.º 2
0
        public static void CheckForPotentiallyMisconfiguredComponents(this IWindsorContainer container)
        {
            var host        = (IDiagnosticsHost)container.Kernel.GetSubSystem(SubSystemConstants.DiagnosticsKey);
            var diagnostics = host.GetDiagnostic <IPotentiallyMisconfiguredComponentsDiagnostic>();

            var handlers = diagnostics.Inspect();

            if (!handlers.Any())
            {
                return;
            }

            var message   = new StringBuilder();
            var inspector = new DependencyInspector(message);

            foreach (IExposeDependencyInfo handler in handlers.Where(h => h.ComponentModel.Implementation.Assembly.FullName.StartsWith("Options.")))
            {
                handler.ObtainDependencyDetails(inspector);
            }

            if (message.Length > 0)
            {
                var ex = new System.Configuration.ConfigurationErrorsException(message.ToString());
                logger.Error("Castle Configuarion Error. Message : {0}\r\nStackTrace {1}", ex.Message, ex.StackTrace);
                throw ex;
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Checks for a malformed settings file and rewrites it.
        /// </summary>
        /// <remarks>Documented by Dev02, 2008-02-18</remarks>
        public static void CheckSettings()
        {
            //check for a malformed settings file (fix for [ML-546] Configuration system failed to initialize)
            try
            {
                Settings.Default.AllowOnlyOneInstance = Settings.Default.AllowOnlyOneInstance;
            }
            catch (System.Configuration.ConfigurationErrorsException exp)
            {
                bool errorfixed = false;
                if (exp.InnerException != null && exp.InnerException is System.Configuration.ConfigurationErrorsException)
                {
                    System.Configuration.ConfigurationErrorsException innerexception = exp.InnerException as System.Configuration.ConfigurationErrorsException;
                    if (System.IO.File.Exists(innerexception.Filename))
                    {
                        try
                        {
                            System.IO.File.Delete(innerexception.Filename);
                            errorfixed = true;
                        }
                        catch { }
                    }
                }
                if (System.IO.File.Exists(exp.Filename))
                {
                    try
                    {
                        System.IO.File.Delete(exp.Filename);
                        errorfixed = true;
                    }
                    catch { }
                }
                if (errorfixed)
                {
                    MainForm.BringToFront();
                    MainForm.TopMost = true;
                    Application.DoEvents();

                    MessageBox.Show(Properties.Resources.INITIALIZE_SETTINGS_ERROR, Properties.Resources.INITIALIZE_SETTINGS_CAPTION);
                    Environment.Exit(-1);
                }
                else
                {
                    throw;
                }
            }
        }
Ejemplo n.º 4
0
        private void ReadConfiguredStart()
        {
            try
            {
                // Get the configured start setting
                m_bUseOpenDNS     = Properties.Settings.Default.UseOpenDNS;
                m_bUseDNSCrypt    = Properties.Settings.Default.UseDNSCrypt;
                m_bUseDNSCryptTCP = Properties.Settings.Default.UseDNSCryptTCP;
                m_bUseInsecure    = Properties.Settings.Default.UseInsecure;
            }
            catch (System.Configuration.ConfigurationErrorsException ex)
            {
                // For some reason, there are problems reading the user.config file
                m_Log.Log(Logging.LOGTYPE.ERROR, "Error in ReadConfiguredStart: " + ex.Message);

                string fileName = "";
                if (!string.IsNullOrEmpty(ex.Filename))
                {
                    fileName = ex.Filename;
                }
                else
                {
                    System.Configuration.ConfigurationErrorsException innerException = ex.InnerException as System.Configuration.ConfigurationErrorsException;
                    if (innerException != null && !string.IsNullOrEmpty(innerException.Filename))
                    {
                        fileName = innerException.Filename;
                    }
                }
                if (System.IO.File.Exists(fileName))
                {
                    // Delete the (empty) user.config file
                    m_Log.Log(Logging.LOGTYPE.DEBUG, "Deleting file: " + fileName);
                    System.IO.File.Delete(fileName);

                    // At this point, the program will crash.  But after a restart, it will re-create the file!
                }
            }
        }
 internal void ReportConfigurationFailure(System.Configuration.ConfigurationErrorsException configurationException)
 {
     instrumentationProvider.FireConfigurationFailureEvent(configurationException);
 }