public void Load() { if (!File.Exists(configfile)) { // File not found, not a tragic error. return; } CfgContainer container = null; XmlSerializer serializer = new XmlSerializer(typeof(CfgContainer)); FileStream stream = new FileStream(configfile, FileMode.Open); try { container = serializer.Deserialize(stream) as CfgContainer; stream.Close(); if (container == null) { throw new ApplicationException("Invalid configuration file."); } container.Configuration = this; this.container = container; } catch (Exception ex) { stream.Close(); throw ex; // rethrow } }