/// <summary> /// Loads all the UserConfiguration /// </summary> private void LoadAll() { if ((SettingsFile.Exists) && (SettingsFile.Length > 0)) { using (FileStream fileStream = SettingsFile.OpenRead()) { BinaryFormatter bf = new BinaryFormatter(); try { // ...we need to help the Assembly resolution process, we have assemlies // in a "Plugins" folder, this folder is not a "known path" and therefore // fails to load the assembly AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve; ReplaceUsersSessionMemory((Hashtable)bf.Deserialize(fileStream)); //fileStream.Flush(); } catch (SerializationException ex) { fileStream.Close(); SettingsFile.CopyTo(SettingsFile.FullName + "." + DateTime.Now.ToString("yyyyMMdd-HHmm") + ".corrupt"); SettingsFile.Delete(); throw new InvalidOperationException( "The Settings Store has become corrupt, Please restart TaskClerk.", ex); } finally { // ...ensure that we unwire from the event once the deserialize process is complete AppDomain.CurrentDomain.AssemblyResolve -= CurrentDomain_AssemblyResolve; } } } }