2 // System.Configuration.ConfigurationException.cs
5 // Duncan Mak (duncan@ximian.com)
7 // (C) Ximian, Inc. http://www.ximian.com
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 using System.Globalization;
33 using System.Runtime.Serialization;
39 namespace System.Configuration
42 public class ConfigurationException : SystemException
45 readonly string filename;
52 [Obsolete ("This class is obsolete. Use System.Configuration.ConfigurationErrorsException")]
54 public ConfigurationException () : this (null)
61 [Obsolete ("This class is obsolete. Use System.Configuration.ConfigurationErrorsException")]
63 public ConfigurationException (string message)
68 protected ConfigurationException (SerializationInfo info, StreamingContext context)
69 : base (info, context)
71 filename = info.GetString ("filename");
72 line = info.GetInt32 ("line");
76 [Obsolete ("This class is obsolete. Use System.Configuration.ConfigurationErrorsException")]
78 public ConfigurationException (string message, Exception inner)
79 : base (message, inner)
85 [Obsolete ("This class is obsolete. Use System.Configuration.ConfigurationErrorsException")]
87 public ConfigurationException (string message, XmlNode node)
90 filename = GetXmlNodeFilename(node);
91 line = GetXmlNodeLineNumber(node);
95 [Obsolete ("This class is obsolete. Use System.Configuration.ConfigurationErrorsException")]
97 public ConfigurationException (string message, Exception inner, XmlNode node)
98 : base (message, inner)
100 filename = GetXmlNodeFilename (node);
101 line = GetXmlNodeLineNumber (node);
105 [Obsolete ("This class is obsolete. Use System.Configuration.ConfigurationErrorsException")]
107 public ConfigurationException (string message, string filename, int line)
110 this.filename = filename;
115 [Obsolete ("This class is obsolete. Use System.Configuration.ConfigurationErrorsException")]
117 public ConfigurationException (string message, Exception inner, string filename, int line)
118 : base (message, inner)
120 this.filename = filename;
131 get { return base.Message; }
139 get { return filename; }
150 public override string Message {
153 if (filename != null && filename.Length != 0) {
155 msg = BareMessage + " (" + filename + " line " + line + ")";
157 msg = BareMessage + " (" + filename + ")";
160 msg = BareMessage + " (line " + line + ")";
173 [Obsolete ("This class is obsolete. Use System.Configuration.ConfigurationErrorsException")]
175 public static string GetXmlNodeFilename (XmlNode node)
177 if (!(node is IConfigXmlNode))
180 return ((IConfigXmlNode) node).Filename;
184 [Obsolete ("This class is obsolete. Use System.Configuration.ConfigurationErrorsException")]
186 public static int GetXmlNodeLineNumber (XmlNode node)
188 if (!(node is IConfigXmlNode))
191 return ((IConfigXmlNode) node).LineNumber;
194 public override void GetObjectData (SerializationInfo info, StreamingContext context)
196 base.GetObjectData (info, context);
197 info.AddValue ("filename", filename);
198 info.AddValue ("line", line);