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
53 [Obsolete ("This class is obsolete. Use System.Configuration.ConfigurationErrorsException")]
55 public ConfigurationException ()
56 : base (Locale.GetText ("There is an error in a configuration setting."))
59 bareMessage = Locale.GetText ("There is an error in a configuration setting.");
64 [Obsolete ("This class is obsolete. Use System.Configuration.ConfigurationErrorsException")]
66 public ConfigurationException (string message)
69 bareMessage = message;
72 protected ConfigurationException (SerializationInfo info, StreamingContext context)
73 : base (info, context)
75 filename = info.GetString ("filename");
76 line = info.GetInt32 ("line");
80 [Obsolete ("This class is obsolete. Use System.Configuration.ConfigurationErrorsException")]
82 public ConfigurationException (string message, Exception inner)
83 : base (message, inner)
85 bareMessage = message;
90 [Obsolete ("This class is obsolete. Use System.Configuration.ConfigurationErrorsException")]
92 public ConfigurationException (string message, XmlNode node)
95 filename = GetXmlNodeFilename(node);
96 line = GetXmlNodeLineNumber(node);
97 bareMessage = message;
101 [Obsolete ("This class is obsolete. Use System.Configuration.ConfigurationErrorsException")]
103 public ConfigurationException (string message, Exception inner, XmlNode node)
104 : base (message, inner)
106 filename = GetXmlNodeFilename (node);
107 line = GetXmlNodeLineNumber (node);
108 bareMessage = message;
112 [Obsolete ("This class is obsolete. Use System.Configuration.ConfigurationErrorsException")]
114 public ConfigurationException (string message, string filename, int line)
117 bareMessage = message;
118 this.filename = filename;
123 [Obsolete ("This class is obsolete. Use System.Configuration.ConfigurationErrorsException")]
125 public ConfigurationException (string message, Exception inner, string filename, int line)
128 bareMessage = message;
129 this.filename = filename;
141 get { return bareMessage; }
150 get { return filename; }
162 public override string Message
165 string baseMsg = base.Message;
166 string f = (filename == null) ? String.Empty : filename;
167 string l = (line == 0) ? String.Empty : (" line " + line);
169 return baseMsg + " (" + f + l + ")";
178 [Obsolete ("This class is obsolete. Use System.Configuration.ConfigurationErrorsException")]
180 public static string GetXmlNodeFilename (XmlNode node)
182 if (!(node is IConfigXmlNode))
185 return ((IConfigXmlNode) node).Filename;
189 [Obsolete ("This class is obsolete. Use System.Configuration.ConfigurationErrorsException")]
191 public static int GetXmlNodeLineNumber (XmlNode node)
193 if (!(node is IConfigXmlNode))
196 return ((IConfigXmlNode) node).LineNumber;
199 public override void GetObjectData (SerializationInfo info, StreamingContext context)
201 base.GetObjectData (info, context);
202 info.AddValue ("filename", filename);
203 info.AddValue ("line", line);