private static Project LoadWithPreviousFormat(XmlElement root)
        {
            Project project = new Project();
            project.loading = true;

            Assembly assembly = Assembly.Load("GBE.TemplateDesigner");
            IProjectItem projectItem = (IProjectItem) assembly.CreateInstance(
                "GBE.TemplateDesigner.QueryTemplate.Template", false,
                BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic,
                null, null, null, null);

            try
            {
                projectItem.Deserialize(root);
            }
            catch (Exception ex)
            {
                throw new InvalidDataException("The save file is corrupt and could not be loaded.", ex);
            }
            project.Add(projectItem);
            project.loading = false;
            project.isReadOnly = true;
            return project;
        }
        /// <exception cref="IOException">
        /// Could not load the project.
        /// </exception>
        /// <exception cref="InvalidDataException">
        /// The save file is corrupt and could not be loaded.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// <paramref name="fileName"/> is empty string.
        /// </exception>
        public static Project Load(string fileName)
        {
            if (string.IsNullOrEmpty(fileName))
                throw new ArgumentException("File name cannot be empty.", "fileName");

            if (!File.Exists(fileName))
                throw new FileNotFoundException("File not found or no read permission.");

            XmlDocument document = new XmlDocument();
            try
            {
                document.Load(fileName);
            }
            catch (Exception ex)
            {
                throw new IOException("Could not load file.", ex);
            }

            XmlElement root = document["Project"];
            if (root == null)
            {

                throw new InvalidDataException("The save file is corrupt and could not be loaded.");

            }

            Project project = new Project();
            project.loading = true;
            try
            {
                project.Deserialize(root);
            }
            catch (Exception ex)
            {
                throw new InvalidDataException("The save file is corrupt and could not be loaded.", ex);
            }
            project.loading = false;
            project.FilePath = fileName;
            project.isReadOnly = project.projectFile.IsReadOnly;

            return project;
        }