public static void InitApp()
        {
            try
            {
                HttpApplicationState Application = HttpContext.Current.Application;
                if (Application.Count == 0)
                {
                    SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), "Application start.");
                }
                else
                {
                    SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), "Application restart.");
                }

                // 11/14/2005 Paul.  Force the reload of the provider and connection strings.
                // Application.Remove("SplendidProvider");
                // 11/28/2005 Paul.  Use Clear() to clear all application variables.
                DataTable dtSystemErrors = Application["SystemErrors"] as DataTable;
                Application.Clear();
                // 11/28/2005 Paul.  Save and restore the system errors table.
                Application["SystemErrors"] = dtSystemErrors;
                InitAppURLs();

                // 11/28/2005 Paul.  Clear all cache variables as well.
                foreach (DictionaryEntry oKey in HttpContext.Current.Cache)
                {
                    string sKey = oKey.Key.ToString();
                    HttpContext.Current.Cache.Remove(sKey);
                }
                // 06/03/2006 Paul.  Clear the cached data that is stored in the Session object.
                if (HttpContext.Current.Session != null)
                {
                    Hashtable hashSessionKeys = new Hashtable();
                    foreach (string sKey in HttpContext.Current.Session.Keys)
                    {
                        hashSessionKeys.Add(sKey, null);
                    }
                    // 06/03/2006 Paul.  We can't remove a key when it is used in the enumerator.
                    foreach (string sKey in hashSessionKeys.Keys)
                    {
                        if (sKey.StartsWith("vwSHORTCUTS_Menu_ByUser") || sKey.StartsWith("vwMODULES_TabMenu_ByUser"))
                        {
                            HttpContext.Current.Session.Remove(sKey);
                        }
                    }
                }

                DbProviderFactory dbf = DbProviderFactories.GetFactory();
                using (IDbConnection con = dbf.CreateConnection())
                {
                    // 07/28/2006 Paul.  Test the database connection and allow an early exit if failed.
                    con.Open();
                }

                // 01/12/2006 Paul.  Separate out the terminology so that it can be called when importing a language pack.
                InitTerminology();

                using (IDbConnection con = dbf.CreateConnection())
                {
                    con.Open();
                    string sSQL;
                    sSQL = "select NAME    " + ControlChars.CrLf
                           + "     , VALUE   " + ControlChars.CrLf
                           + "  from vwCONFIG" + ControlChars.CrLf;
                    using (IDbCommand cmd = con.CreateCommand())
                    {
                        cmd.CommandText = sSQL;
                        using (IDataReader rdr = cmd.ExecuteReader())
                        {
                            while (rdr.Read())
                            {
                                Application["CONFIG." + Sql.ToString(rdr["NAME"])] = Sql.ToString(rdr["VALUE"]);
                            }
                        }
                    }
                    sSQL = "select *          " + ControlChars.CrLf
                           + "  from vwTIMEZONES" + ControlChars.CrLf;
                    using (IDbCommand cmd = con.CreateCommand())
                    {
                        cmd.CommandText = sSQL;
                        using (IDataReader rdr = cmd.ExecuteReader())
                        {
                            while (rdr.Read())
                            {
                                TimeZone oTimeZone = new TimeZone
                                                         (Sql.ToGuid(rdr["ID"])
                                                         , Sql.ToString(rdr["NAME"])
                                                         , Sql.ToString(rdr["STANDARD_NAME"])
                                                         , Sql.ToString(rdr["STANDARD_ABBREVIATION"])
                                                         , Sql.ToString(rdr["DAYLIGHT_NAME"])
                                                         , Sql.ToString(rdr["DAYLIGHT_ABBREVIATION"])
                                                         , Sql.ToInteger(rdr["BIAS"])
                                                         , Sql.ToInteger(rdr["STANDARD_BIAS"])
                                                         , Sql.ToInteger(rdr["DAYLIGHT_BIAS"])
                                                         , Sql.ToInteger(rdr["STANDARD_YEAR"])
                                                         , Sql.ToInteger(rdr["STANDARD_MONTH"])
                                                         , Sql.ToInteger(rdr["STANDARD_WEEK"])
                                                         , Sql.ToInteger(rdr["STANDARD_DAYOFWEEK"])
                                                         , Sql.ToInteger(rdr["STANDARD_HOUR"])
                                                         , Sql.ToInteger(rdr["STANDARD_MINUTE"])
                                                         , Sql.ToInteger(rdr["DAYLIGHT_YEAR"])
                                                         , Sql.ToInteger(rdr["DAYLIGHT_MONTH"])
                                                         , Sql.ToInteger(rdr["DAYLIGHT_WEEK"])
                                                         , Sql.ToInteger(rdr["DAYLIGHT_DAYOFWEEK"])
                                                         , Sql.ToInteger(rdr["DAYLIGHT_HOUR"])
                                                         , Sql.ToInteger(rdr["DAYLIGHT_MINUTE"])
                                                         , Sql.ToBoolean(Application["CONFIG.GMT_Storage"])
                                                         );
                                Application["TIMEZONE." + oTimeZone.ID.ToString()] = oTimeZone;
                            }
                        }
                    }
                    sSQL = "select *           " + ControlChars.CrLf
                           + "  from vwCURRENCIES" + ControlChars.CrLf;
                    using (IDbCommand cmd = con.CreateCommand())
                    {
                        cmd.CommandText = sSQL;
                        using (IDataReader rdr = cmd.ExecuteReader())
                        {
                            while (rdr.Read())
                            {
                                Currency C10n = new Currency
                                                    (Sql.ToGuid(rdr["ID"])
                                                    , Sql.ToString(rdr["NAME"])
                                                    , Sql.ToString(rdr["SYMBOL"])
                                                    , Sql.ToFloat(rdr["CONVERSION_RATE"])
                                                    );
                                Application["CURRENCY." + C10n.ID.ToString()] = C10n;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message);
                //HttpContext.Current.Response.Write(ex.Message);
            }
        }