/// <summary>
        /// Saves the into the location where the executing assembly (.exe file)
        /// resides
        /// </summary>
        /// <param name="config">Config file that should be saved</param>
        /// <exception cref="T:System.Exception">
        /// The serialization of the file failed
        /// </exception>
        public static void Save(FrontEndConfig config)
        {
            //getting the name of the executing assembly (should be FerdaFrontEnd.exe)
            string assembly = Assembly.GetExecutingAssembly().FullName;

            //getting the name of the exe program (without the suffix)
            assembly = assembly.Substring(0, assembly.IndexOf(','));
            //adding the suffix
            assembly += ".dll";
            //getting the full location fo the .exe file
            StringBuilder str = new StringBuilder(Assembly.GetExecutingAssembly().Location);

            //replacing the .exe by the name of the config file
            str.Replace(assembly, FileName);

            System.IO.FileStream fs = null;
            try
            {
                fs = new System.IO.FileStream(str.ToString(), System.IO.FileMode.Create);
                XmlSerializer s = new XmlSerializer(typeof(FrontEndConfig));
                TextWriter    w = new StreamWriter(fs);
                s.Serialize(w, config);
                w.Close();
            }
            catch (Exception e)
            {
                throw new Exception("Application was not able to save FrontEndConfig.xml", e);
            }
            finally
            {
                fs.Close();
            }
        }
        /// <summary>
        /// Loads the FrontEndConfig.xml file from the directory, where
        /// the FerdaFrontEnd.exe file is located
        /// </summary>
        /// <exception cref="T:System.Exception">
        /// The loading of the file failed (perhaps the file is not there)
        /// </exception>
        /// <returns>FrontEndConfig object that contains project configuration info
        /// </returns>
        public static FrontEndConfig Load()
        {
            // cesta a nazev file FrontEndConfig
            string str = DirManager.get_FerdaFrontEnd_dir() + @"\FrontEndConfig.xml";

            System.IO.FileStream fs;
            //tries to open the file
            try
            {
                fs = new System.IO.FileStream(str.ToString(), System.IO.FileMode.Open);
            }
            catch (Exception e)
            {
                throw new FE_error("FEP002");
            }

            FrontEndConfig config = new FrontEndConfig();

            //tries to deserialize the FrontEndConfig.xml file
            try
            {
                XmlSerializer s = new XmlSerializer(typeof(FrontEndConfig));
                TextReader    r = new StreamReader(fs);
                config = (FrontEndConfig)s.Deserialize(r);
                r.Close();
            }
            finally
            {
                fs.Close();
            }
            return(config);
        }
        /// <summary>
        /// Static construktor - loading of iceConfig
        /// </summary>
        static FEplugin_globals()
        {
            #region loading of iceConfig
            try
            {
                FEplugin_globals.iceConfig = FrontEndConfig.Load();

                //if (FEplugin_globals.iceConfig.ProjectManagerOptions.IceGridAsService != true)  // IceGrid musi byt spusteno jako sluzba
                //    FEplugin_globals.iceConfig.ProjectManagerOptions.IceGridAsService = true;
                //if (FEplugin_globals.iceConfig.ProjectManagerOptions.StartIceGridLocaly != true)
                //    FEplugin_globals.iceConfig.ProjectManagerOptions.StartIceGridLocaly = true;
                //if (FEplugin_globals.iceConfig.ProjectManagerOptions.StopIceGridLocaly != false)
                //    FEplugin_globals.iceConfig.ProjectManagerOptions.StopIceGridLocaly = false;

                iceConfig_initialized = true;
            }
            catch (FE_error e)
            {
                if (e.code == "FEP002")  // initialization of iceConfig failed
                {
                    iceConfig_initialized = false;
                }
            }

            #endregion
        }
        /// <summary>
        /// Loads the FrontEndConfig.xml file from the directory, where
        /// the FerdaFrontEnd.exe file is located
        /// </summary>
        /// <exception cref="T:System.Exception">
        /// The loading of the file failed (perhaps the file is not there)
        /// </exception>
        /// <returns>FrontEndConfig object that contains project configuration info
        /// </returns>
        public static FrontEndConfig Load()
        {
            // cesta a nazev file FrontEndConfig
            string str = DirManager.get_FerdaFrontEnd_dir() + @"\FrontEndConfig.xml";

            System.IO.FileStream fs;
            //tries to open the file
            try
            {
                fs = new System.IO.FileStream(str.ToString(), System.IO.FileMode.Open);
            }
            catch (Exception e)
            {
                throw new FE_error("FEP002");
            }

            FrontEndConfig config = new FrontEndConfig();

            //tries to deserialize the FrontEndConfig.xml file
            try
            {
                XmlSerializer s = new XmlSerializer(typeof(FrontEndConfig));
                TextReader r = new StreamReader(fs);
                config = (FrontEndConfig)s.Deserialize(r);
                r.Close();
            }
            finally
            {
                fs.Close();
            }
            return config;
        }
        /// <summary>
        /// Static construktor - loading of iceConfig
        /// </summary>
        static FEplugin_globals()
        {
            #region loading of iceConfig
            try
            {
                FEplugin_globals.iceConfig = FrontEndConfig.Load();

                //if (FEplugin_globals.iceConfig.ProjectManagerOptions.IceGridAsService != true)  // IceGrid musi byt spusteno jako sluzba
                //    FEplugin_globals.iceConfig.ProjectManagerOptions.IceGridAsService = true;
                //if (FEplugin_globals.iceConfig.ProjectManagerOptions.StartIceGridLocaly != true)
                //    FEplugin_globals.iceConfig.ProjectManagerOptions.StartIceGridLocaly = true;
                //if (FEplugin_globals.iceConfig.ProjectManagerOptions.StopIceGridLocaly != false)
                //    FEplugin_globals.iceConfig.ProjectManagerOptions.StopIceGridLocaly = false;

                iceConfig_initialized = true;
            }
            catch (FE_error e)
            {
                if(e.code == "FEP002")  // initialization of iceConfig failed
                    iceConfig_initialized = false;
            }

            #endregion
        }
        /// <summary>
        /// Saves the into the location where the executing assembly (.exe file) 
        /// resides
        /// </summary>
        /// <param name="config">Config file that should be saved</param>
        /// <exception cref="T:System.Exception">
        /// The serialization of the file failed
        /// </exception> 
        public static void Save(FrontEndConfig config)
        {
            //getting the name of the executing assembly (should be FerdaFrontEnd.exe)
            string assembly = Assembly.GetExecutingAssembly().FullName;
            //getting the name of the exe program (without the suffix)
            assembly = assembly.Substring(0, assembly.IndexOf(','));
            //adding the suffix
            assembly += ".dll";
            //getting the full location fo the .exe file
            StringBuilder str = new StringBuilder(Assembly.GetExecutingAssembly().Location);
            //replacing the .exe by the name of the config file
            str.Replace(assembly, FileName);

            System.IO.FileStream fs = null;
            try
            {
                fs = new System.IO.FileStream(str.ToString(), System.IO.FileMode.Create);
                XmlSerializer s = new XmlSerializer(typeof(FrontEndConfig));
                TextWriter w = new StreamWriter(fs);
                s.Serialize(w, config);
                w.Close();
            }
            catch (Exception e)
            {
                throw new Exception("Application was not able to save FrontEndConfig.xml", e);
            }
            finally
            {
                fs.Close();
            }
        }