Inheritance: System.SystemException
Exemplo n.º 1
0
		[Test] // ctor (String)
		public void Constructor2 ()
		{
			string msg;
			ConfigurationException ce;

			msg = "MSG";
			ce = new ConfigurationException (msg);
			Assert.AreSame (msg, ce.BareMessage, "#A1");
			Assert.IsNotNull (ce.Data, "#A2");
			Assert.AreEqual (0, ce.Data.Count, "#A3");
			Assert.IsNull (ce.Filename, "#A4");
			Assert.IsNull (ce.InnerException, "#A5");
			Assert.AreEqual (0, ce.Line, "#A6");
			Assert.AreSame (msg, ce.Message, "#A7");

			msg = null;
			ce = new ConfigurationException (msg);

			Assert.AreEqual (new ConfigurationException ().Message, ce.BareMessage, "#B1");
			Assert.IsNotNull (ce.Data, "#B2");
			Assert.AreEqual (0, ce.Data.Count, "#B3");
			Assert.IsNull (ce.Filename, "#B4");
			Assert.IsNull (ce.InnerException, "#B5");
			Assert.AreEqual (0, ce.Line, "#B6");
			Assert.AreEqual (ce.BareMessage, ce.Message, "#B7");
		}
Exemplo n.º 2
0
		[Test] // ctor (String)
		public void Constructor2 ()
		{
			string msg;
			ConfigurationException ce;

			msg = "MSG";
			ce = new ConfigurationException (msg);
			Assert.AreSame (msg, ce.BareMessage, "#A1");
#if NET_2_0
			Assert.IsNotNull (ce.Data, "#A2");
			Assert.AreEqual (0, ce.Data.Count, "#A3");
#endif
			Assert.IsNull (ce.Filename, "#A4");
			Assert.IsNull (ce.InnerException, "#A5");
			Assert.AreEqual (0, ce.Line, "#A6");
			Assert.AreSame (msg, ce.Message, "#A7");

			msg = null;
			ce = new ConfigurationException (msg);

#if NET_2_0
			Assert.AreEqual (new ConfigurationException ().Message, ce.BareMessage, "#B1");
			Assert.IsNotNull (ce.Data, "#B2");
			Assert.AreEqual (0, ce.Data.Count, "#B3");
#else
			Assert.IsNotNull (ce.BareMessage, "#B1");
			Assert.IsTrue (ce.BareMessage.IndexOf (typeof (ConfigurationException).FullName) != -1, "#B2");
#endif
			Assert.IsNull (ce.Filename, "#B4");
			Assert.IsNull (ce.InnerException, "#B5");
			Assert.AreEqual (0, ce.Line, "#B6");
			Assert.AreEqual (ce.BareMessage, ce.Message, "#B7");
		}
        internal void SetSingleGlobalError(ConfigurationException ce) {
            _errorsAll = null;
            _errorsLocal = null;
            _errorsGlobal = null;

            AddError(ce, ExceptionAction.Global);
        }
 internal ConfigErrorFormatter(ConfigurationException e) : base(null, e.Filename, null, e.Line)
 {
     this._adaptiveMiscContent = new StringCollection();
     this._e = e;
     PerfCounters.IncrementCounter(AppPerfCounter.ERRORS_PRE_PROCESSING);
     PerfCounters.IncrementCounter(AppPerfCounter.ERRORS_TOTAL);
     this._message = HttpUtility.FormatPlainTextAsHtml(e.BareMessage);
     this._adaptiveMiscContent.Add(this._message);
 }
 private ConfigurationException[] GetReadOnlyErrorsList()
 {
     ArrayList errorsList = this._thisElement.GetErrorsList();
     int count = errorsList.Count;
     ConfigurationException[] array = new ConfigurationException[errorsList.Count];
     if (count != 0)
     {
         errorsList.CopyTo(array, 0);
     }
     return array;
 }
Exemplo n.º 6
0
		[Test] // ctor ()
		public void Constructor1 ()
		{
			ConfigurationException ce = new ConfigurationException ();
			Assert.IsNotNull (ce.BareMessage, "#1");
			Assert.IsTrue (ce.BareMessage.IndexOf ("'" + typeof (ConfigurationException).FullName + "'") != -1, "#2:" + ce.BareMessage);
			Assert.IsNotNull (ce.Data, "#3");
			Assert.AreEqual (0, ce.Data.Count, "#4");
			Assert.IsNull (ce.Filename, "#5");
			Assert.IsNull (ce.InnerException, "#6");
			Assert.AreEqual (0, ce.Line, "#7");
			Assert.AreEqual (ce.BareMessage, ce.Message, "#8");
		}
Exemplo n.º 7
0
        private ConfigurationException[] GetReadOnlyErrorsList()
        {
            int count;

            ArrayList arrayList = _thisElement.GetErrorsList();
            count = arrayList.Count;

            // Create readonly array
            ConfigurationException[] exceptionList = new ConfigurationException[arrayList.Count];

            if (count != 0) arrayList.CopyTo(exceptionList, 0);

            return exceptionList;
        }
        //
        // Add a configuration Error.
        //
        internal void AddError(ConfigurationException ce, ExceptionAction action) {
            switch (action) {
                case ExceptionAction.Global:
                    ErrorsHelper.AddError(ref _errorsAll, ce);
                    ErrorsHelper.AddError(ref _errorsGlobal, ce);
                    break;

                case ExceptionAction.NonSpecific:
                    ErrorsHelper.AddError(ref _errorsAll, ce);
                    break;

                case ExceptionAction.Local:
                    ErrorsHelper.AddError(ref _errorsLocal, ce);
                    break;
            }
        }
Exemplo n.º 9
0
        internal static void AddError(ref List<ConfigurationException> errors, ConfigurationException e)
        {
            Debug.Assert(e != null, "e != null");

            // Create on demand
            if (errors == null) errors = new List<ConfigurationException>();

            ConfigurationErrorsException ce = e as ConfigurationErrorsException;
            if (ce == null) errors.Add(e);
            else
            {
                ICollection<ConfigurationException> col = ce.ErrorsGeneric;
                if (col.Count == 1) errors.Add(e);
                else errors.AddRange(col);
            }
        }
 internal static void AddError(ref List<ConfigurationException> errors, ConfigurationException e)
 {
     if (errors == null)
     {
         errors = new List<ConfigurationException>();
     }
     ConfigurationErrorsException exception = e as ConfigurationErrorsException;
     if (exception == null)
     {
         errors.Add(e);
     }
     else
     {
         ICollection<ConfigurationException> errorsGeneric = exception.ErrorsGeneric;
         if (errorsGeneric.Count == 1)
         {
             errors.Add(e);
         }
         else
         {
             errors.AddRange(errorsGeneric);
         }
     }
 }
Exemplo n.º 11
0
        private static void DeleteInvalidUserFileFromException(ConfigurationException ex)
        {
            Console.WriteLine("User Config file is invalid - resetting to default");

            string fileName = "";

            if (!string.IsNullOrEmpty(ex.Filename))
            {
                fileName = ex.Filename;
            }
            else
            {
                var innerException =
                    ex.InnerException as ConfigurationErrorsException;
                if (innerException != null && !string.IsNullOrEmpty(innerException.Filename))
                {
                    fileName = innerException.Filename;
                }
            }
            if (File.Exists(fileName))
            {
                File.Delete(fileName);
            }
        }
 internal InvalidPropValue(string value, ConfigurationException error) {
     _value = value;
     _error = error;
 }
Exemplo n.º 13
0
 internal void AddError(ConfigurationException e)
 {
     ErrorsHelper.AddError(ref _errors, e);
 }
Exemplo n.º 14
0
 internal ConfigurationErrorsException(ConfigurationException e) :
     this(e?.BareMessage, e?.InnerException, e?.Filename, e?.Line ?? 0)
 { }
        /// <summary>
        /// Default constructor
        /// </summary>
        public ApplicationUpdateManager()
        {
            DnldMgrHolder holder;

            //  initialize the hybriddict we're using to hold DnldMgrHolder structs
            _dnldHolders = new HybridDictionary();

            #region Configuration Testing

            //  attempt to load configuration first.  If there is an error, throw here and go no further--config is essential
            try
            {
                UpdaterConfiguration config = UpdaterConfiguration.Instance;
            }
            catch( Exception e )
            {
                //  throw right away after logging, we cannot continue
                ExceptionManager.Publish( e );
                throw e;
            }
            #endregion

            #region Set Up File-Based Logging

            SetupLogging();

            #endregion

            #region Create Managers, Create Validator + Downloader, Construct Managers with their respective objects (downloader + validator)

            //  iterate through applications array (which in turn uses config to get this info)
            //  at each application, create a new DownloaderManager + its objects + attendant thread
            foreach( ApplicationConfiguration application in UpdaterConfiguration.Instance.Applications )
            {
                //  use helper function to create + package a complete DnldMgrHolder + the inner DownloaderManager and all its parts
                holder = SetupDownloadManager( application );
                //  check if app of this name exists already; CANNOT HAVE two apps of same name being updated
                if( _dnldHolders.Contains( application.Name ) )
                {
                    string error = ApplicationUpdateManager.TraceWrite( "[ApplicationUpdateManager.ctor]", "RES_EXCEPTION_DuplicateApplicationName", application.Name );
                    ConfigurationException configE = new ConfigurationException( error );
                    ExceptionManager.Publish( configE );
                    throw configE;
                }
                //  add the holder to the hashtable for starting later
                _dnldHolders.Add( application.Name,  holder );
            }

            #endregion

            #region Hook ProcessExit

            //  wrap in try in case security not allowing us to hook this, log and continue it's not crucial
            try
            {
                //  hook the AppDomain.ProcessExit event so that we can gracefully interrupt threads and clean up if
                //  process is killed
                AppDomain.CurrentDomain.ProcessExit += new EventHandler(CurrentDomain_ProcessExit);
            }
            catch( SecurityException se )
            {
                //  log and continue
                ApplicationUpdateManager.TraceWrite( se, "[ApplicationUpdateManager.CTOR]", "RES_EXCEPTION_ConfigCantLoadInAUConstructor" );
                ExceptionManager.Publish ( se );
            }

            #endregion
        }
Exemplo n.º 16
0
		[Test] // ctor (String, Exception, String, Int32)
		public void Constructor7 ()
		{
			string msg;
			Exception inner;
			string filename;
			int line;
			ConfigurationException ce;

			msg = "MSG";
			inner = new Exception ();
			filename = "abc.txt";
			line = 7;
			ce = new ConfigurationException (msg, inner, filename, line);
			Assert.AreSame (msg, ce.BareMessage, "#A1");
			Assert.IsNotNull (ce.Data, "#A2");
			Assert.AreEqual (0, ce.Data.Count, "#A3");
			Assert.AreSame (filename, ce.Filename, "#A4");
			Assert.AreSame (inner, ce.InnerException, "#A5");
			Assert.AreEqual (line, ce.Line, "#A6");
			Assert.AreEqual (msg + " (abc.txt line 7)", ce.Message, "#A7");

			msg = null;
			inner = null;
			filename = null;
			line = 0;
			ce = new ConfigurationException (msg, inner, filename, line);
			Assert.AreEqual (new ConfigurationException ().Message, ce.BareMessage, "#B1");
			Assert.IsNotNull (ce.Data, "#B2");
			Assert.AreEqual (0, ce.Data.Count, "#B3");
			Assert.AreSame (filename, ce.Filename, "#B4");
			Assert.AreSame (inner, ce.InnerException, "#B5");
			Assert.AreEqual (0, ce.Line, "#B6");
			Assert.AreEqual (ce.BareMessage, ce.Message, "#B7");

			msg = null;
			inner = new Exception ();
			filename = null;
			line = 7;
			ce = new ConfigurationException (msg, inner, filename, line);
			Assert.AreEqual (new ConfigurationException ().Message, ce.BareMessage, "#C1");
			Assert.IsNotNull (ce.Data, "#C2");
			Assert.AreEqual (0, ce.Data.Count, "#C3");
			Assert.AreSame (filename, ce.Filename, "#C4");
			Assert.AreSame (inner, ce.InnerException, "#C5");
			Assert.AreEqual (line, ce.Line, "#C6");
			Assert.AreEqual (ce.BareMessage + " (line 7)", ce.Message, "#C7");

			msg = string.Empty;
			inner = new Exception ();
			filename = string.Empty;
			line = 7;
			ce = new ConfigurationException (msg, inner, filename, line);
			Assert.AreSame (msg, ce.BareMessage, "#D1");
			Assert.IsNotNull (ce.Data, "#D2");
			Assert.AreEqual (0, ce.Data.Count, "#D3");
			Assert.AreSame (filename, ce.Filename, "#D4");
			Assert.AreSame (inner, ce.InnerException, "#D5");
			Assert.AreEqual (line, ce.Line, "#D6");
			Assert.AreEqual (" (line 7)", ce.Message, "#D7");

			msg = string.Empty;
			inner = new Exception ();
			filename = "abc.txt";
			line = 7;
			ce = new ConfigurationException (msg, inner, filename, line);
			Assert.AreSame (msg, ce.BareMessage, "#E1");
			Assert.IsNotNull (ce.Data, "#E2");
			Assert.AreEqual (0, ce.Data.Count, "#E3");
			Assert.AreSame (filename, ce.Filename, "#E4");
			Assert.AreSame (inner, ce.InnerException, "#E5");
			Assert.AreEqual (line, ce.Line, "#E6");
			Assert.AreEqual (" (abc.txt line 7)", ce.Message, "#E7");

			msg = "MSG";
			inner = new Exception ();
			filename = null;
			line = 7;
			ce = new ConfigurationException (msg, inner, filename, line);
			Assert.AreSame (msg, ce.BareMessage, "#F1");
			Assert.IsNotNull (ce.Data, "#F2");
			Assert.AreEqual (0, ce.Data.Count, "#F3");
			Assert.AreSame (filename, ce.Filename, "#F4");
			Assert.AreSame (inner, ce.InnerException, "#F5");
			Assert.AreEqual (line, ce.Line, "#F6");
			Assert.AreEqual (ce.BareMessage + " (line 7)", ce.Message, "#F7");

			msg = null;
			inner = new Exception ();
			filename = "abc.txt";
			line = 7;
			ce = new ConfigurationException (msg, inner, filename, line);
			Assert.AreEqual (new ConfigurationException ().Message, ce.BareMessage, "#G1");
			Assert.IsNotNull (ce.Data, "#G2");
			Assert.AreEqual (0, ce.Data.Count, "#G3");
			Assert.AreSame (filename, ce.Filename, "#G4");
			Assert.AreSame (inner, ce.InnerException, "#G5");
			Assert.AreEqual (line, ce.Line, "#G6");
			Assert.AreEqual (ce.BareMessage + " (abc.txt line 7)", ce.Message, "#G7");
		}
 private static Exception GetInnerException(ConfigurationException e)
 {
     return(e?.InnerException);
 }
 private static string GetUnsafeFilename(ConfigurationException e)
 {
     if (e != null)
     {
         return e.Filename;
     }
     return null;
 }
 private static Exception GetInnerException(ConfigurationException e)
 {
     if (e != null)
     {
         return e.InnerException;
     }
     return null;
 }
Exemplo n.º 20
0
        /// <summary>
        /// <para>Create the default insance of the provider object.</para>
        /// </summary>
        /// <returns>
        /// <para>The default provider object instance.</para>
        /// </returns>
        protected virtual object CreateDefaultInstance()
        {
            string defaultName = GetDefaultInstanceName();
            if ((null == type))
            {
                ConfigurationException ex = new ConfigurationException(SR.ExceptionDefaultProviderNotSpecified(FactoryName));
                PublishFailureEvent(defaultName, ex);
                throw ex;
            }

            return CreateInstance(defaultName);
        }
 private static string GetBareMessage(ConfigurationException e)
 {
     if (e != null)
     {
         return e.BareMessage;
     }
     return null;
 }
Exemplo n.º 22
0
		[Test] // ctor (String, Exception, XmlNode)
		public void Constructor5 ()
		{
			string msg;
			Exception inner;
			XmlNode node;
			ConfigurationException ce;

			msg = "MSG";
			inner = new Exception ();
			node = new XmlDocument ();
			ce = new ConfigurationException (msg, inner, node);
			Assert.AreSame (msg, ce.BareMessage, "#A1");
			Assert.IsNotNull (ce.Data, "#A2");
			Assert.AreEqual (0, ce.Data.Count, "#A3");
			Assert.AreEqual (string.Empty, ce.Filename, "#A4");
			Assert.AreSame (inner, ce.InnerException, "#A5");
			Assert.AreEqual (0, ce.Line, "#A6");
			Assert.AreSame (msg, ce.Message, "#A7");

			msg = null;
			inner = null;
			node = null;
			ce = new ConfigurationException (msg, inner, node);
			Assert.AreEqual (new ConfigurationException ().Message, ce.BareMessage, "#B1");
			Assert.IsNotNull (ce.Data, "#B2");
			Assert.AreEqual (0, ce.Data.Count, "#B3");
			Assert.AreEqual (string.Empty, ce.Filename, "#B4");
			Assert.AreSame (inner, ce.InnerException, "#B5");
			Assert.AreEqual (0, ce.Line, "#B6");
			Assert.AreEqual (ce.BareMessage, ce.Message, "#B7");
		}
 private static int GetLineNumber(ConfigurationException e)
 {
     if (e != null)
     {
         return e.Line;
     }
     return 0;
 }
Exemplo n.º 24
0
		[Test] // ctor (String, String, Int32)
		public void Constructor6 ()
		{
			string msg;
			string filename;
			int line;
			ConfigurationException ce;

			msg = "MSG";
			filename = "abc.txt";
			line = 7;
			ce = new ConfigurationException (msg, filename, line);
			Assert.AreSame (msg, ce.BareMessage, "#A1");
			Assert.IsNotNull (ce.Data, "#A2");
			Assert.AreEqual (0, ce.Data.Count, "#A3");
			Assert.AreSame (filename, ce.Filename, "#A4");
			Assert.IsNull (ce.InnerException, "#A5");
			Assert.AreEqual (line, ce.Line, "#A6");
			Assert.AreEqual ("MSG (abc.txt line 7)", ce.Message, "#A7");

			msg = null;
			filename = null;
			line = 0;
			ce = new ConfigurationException (msg, filename, line);
			Assert.AreEqual (new ConfigurationException ().Message, ce.BareMessage, "#B1");
			Assert.IsNotNull (ce.Data, "#B3");
			Assert.AreEqual (0, ce.Data.Count, "#B4");
			Assert.AreSame (filename, ce.Filename, "#B5");
			Assert.IsNull (ce.InnerException, "#B6");
			Assert.AreEqual (0, ce.Line, "#B7");
			Assert.AreEqual (ce.BareMessage, ce.Message, "#B8");

			msg = null;
			filename = "abc.txt";
			line = 5;
			ce = new ConfigurationException (msg, filename, line);
			Assert.AreEqual (new ConfigurationException ().Message, ce.BareMessage, "#C1");
			Assert.IsNotNull (ce.Data, "#C2");
			Assert.AreEqual (0, ce.Data.Count, "#C3");
			Assert.AreSame (filename, ce.Filename, "#C4");
			Assert.IsNull (ce.InnerException, "#C5");
			Assert.AreEqual (5, ce.Line, "#C6");
			Assert.AreEqual (ce.BareMessage + " (abc.txt line 5)", ce.Message, "#C7");

			msg = "MSG";
			filename = null;
			line = 5;
			ce = new ConfigurationException (msg, filename, line);
			Assert.AreSame (msg, ce.BareMessage, "#D1");
			Assert.IsNotNull (ce.Data, "#D2");
			Assert.AreEqual (0, ce.Data.Count, "#D3");
			Assert.AreSame (filename, ce.Filename, "#D4");
			Assert.IsNull (ce.InnerException, "#D5");
			Assert.AreEqual (5, ce.Line, "#D6");
			Assert.AreEqual (msg + " (line 5)", ce.Message, "#D7");

			msg = "MSG";
			filename = "abc.txt";
			line = 0;
			ce = new ConfigurationException (msg, filename, line);
			Assert.AreSame (msg, ce.BareMessage, "#E1");
			Assert.IsNotNull (ce.Data, "#E2");
			Assert.AreEqual (0, ce.Data.Count, "#E3");
			Assert.AreSame (filename, ce.Filename, "#E4");
			Assert.IsNull (ce.InnerException, "#E5");
			Assert.AreEqual (0, ce.Line, "#E6");
			Assert.AreEqual (msg + " (abc.txt)", ce.Message, "#E7");

			msg = null;
			filename = null;
			line = 4;
			ce = new ConfigurationException (msg, filename, line);
			Assert.AreEqual (new ConfigurationException ().Message, ce.BareMessage, "#F1");
			Assert.IsNotNull (ce.Data, "#F2");
			Assert.AreEqual (0, ce.Data.Count, "#F3");
			Assert.AreSame (filename, ce.Filename, "#F4");
			Assert.IsNull (ce.InnerException, "#F5");
			Assert.AreEqual (4, ce.Line, "#F6");
			Assert.AreEqual (ce.BareMessage + " (line 4)", ce.Message, "#F7");

			msg = string.Empty;
			filename = string.Empty;
			line = 0;
			ce = new ConfigurationException (msg, filename, line);
			Assert.AreSame (msg, ce.BareMessage, "#G1");
			Assert.IsNotNull (ce.Data, "#G2");
			Assert.AreEqual (0, ce.Data.Count, "#G3");
			Assert.AreSame (filename, ce.Filename, "#G4");
			Assert.IsNull (ce.InnerException, "#G5");
			Assert.AreEqual (0, ce.Line, "#G6");
			Assert.AreSame (msg, ce.Message, "#G7");

			msg = string.Empty;
			filename = "abc.txt";
			line = 6;
			ce = new ConfigurationException (msg, filename, line);
			Assert.AreSame (msg, ce.BareMessage, "#H1");
			Assert.IsNotNull (ce.Data, "#H2");
			Assert.AreEqual (0, ce.Data.Count, "#H3");
			Assert.AreSame (filename, ce.Filename, "#H4");
			Assert.IsNull (ce.InnerException, "#H5");
			Assert.AreEqual (6, ce.Line, "#H6");
			Assert.AreEqual (msg + " (abc.txt line 6)", ce.Message, "#H7");

			msg = "MSG";
			filename = string.Empty;
			line = 6;
			ce = new ConfigurationException (msg, filename, line);
			Assert.AreSame (msg, ce.BareMessage, "#I1");
			Assert.IsNotNull (ce.Data, "#I2");
			Assert.AreEqual (0, ce.Data.Count, "#I3");
			Assert.AreSame (filename, ce.Filename, "#I4");
			Assert.IsNull (ce.InnerException, "#I5");
			Assert.AreEqual (6, ce.Line, "#I6");
			Assert.AreEqual (msg + " (line 6)", ce.Message, "#I7");

			msg = string.Empty;
			filename = string.Empty;
			line = 4;
			ce = new ConfigurationException (msg, filename, line);
			Assert.AreSame (msg, ce.BareMessage, "#J1");
			Assert.IsNotNull (ce.Data, "#J2");
			Assert.AreEqual (0, ce.Data.Count, "#J3");
			Assert.AreSame (filename, ce.Filename, "#J4");
			Assert.IsNull (ce.InnerException, "#J5");
			Assert.AreEqual (4, ce.Line, "#J6");
			Assert.AreEqual (msg + " (line 4)", ce.Message, "#J7");

			msg = "MSG";
			filename = string.Empty;
			line = 0;
			ce = new ConfigurationException (msg, filename, line);
			Assert.AreSame (msg, ce.BareMessage, "#K1");
			Assert.IsNotNull (ce.Data, "#K2");
			Assert.AreEqual (0, ce.Data.Count, "#K3");
			Assert.AreSame (filename, ce.Filename, "#K4");
			Assert.IsNull (ce.InnerException, "#K5");
			Assert.AreEqual (0, ce.Line, "#K6");
			Assert.AreEqual (msg, ce.Message, "#K7");
		}
 internal ConfigurationErrorsException(ConfigurationException e) : this(GetBareMessage(e), GetInnerException(e), GetUnsafeFilename(e), GetLineNumber(e))
 {
 }
 private static string GetBareMessage(ConfigurationException e)
 {
     return(e?.BareMessage);
 }