2 // System.IO.FileLoadException.cs
5 // Paolo Molaro (lupus@ximian.com)
6 // Duncan Mak (duncan@ximian.com)
8 // (C) 2001 Ximian, Inc. http://www.ximian.com
9 // Copyright (C) 2004-2005 Novell, Inc (http://www.novell.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.
31 using System.Globalization;
32 using System.Runtime.Serialization;
33 using System.Security;
34 using System.Security.Permissions;
38 using System.Runtime.InteropServices;
47 public class FileLoadException : IOException {
50 const int Result = unchecked ((int)0x80070002);
56 public FileLoadException ()
57 : base (Locale.GetText ("I/O Error"))
60 msg = Locale.GetText ("I/O Error");
63 public FileLoadException (string message)
70 public FileLoadException (string message, string fileName)
75 this.fileName = fileName;
78 public FileLoadException (string message, Exception inner)
79 : base (message, inner)
85 public FileLoadException (string message, string fileName, Exception inner)
86 : base (message, inner)
90 this.fileName = fileName;
93 protected FileLoadException (SerializationInfo info, StreamingContext context)
95 fileName = info.GetString ("FileLoad_FileName");
96 fusionLog = info.GetString ("FileLoad_FusionLog");
100 public override string Message {
104 public string FileName
106 get { return fileName; }
109 public string FusionLog {
110 // note: MS runtime throws a SecurityException when the Exception is created
111 // but a FileLoadException once the exception as been thrown. Mono always
112 // throw a SecurityException in both case (anyway fusionLog is currently empty)
113 [SecurityPermission (SecurityAction.Demand, ControlEvidence=true, ControlPolicy=true)]
114 get { return fusionLog; }
118 public override void GetObjectData (SerializationInfo info, StreamingContext context)
120 base.GetObjectData (info, context);
121 info.AddValue ("FileLoad_FileName", fileName);
122 info.AddValue ("FileLoad_FusionLog", fusionLog);
125 public override string ToString ()
127 StringBuilder sb = new StringBuilder (GetType ().FullName);
128 sb.AppendFormat (": {0}", msg);
130 if (fileName != null)
131 sb.AppendFormat (" : {0}", fileName);
133 if (this.InnerException != null)
134 sb.AppendFormat (" ----> {0}", InnerException);
136 if (this.StackTrace != null) {
137 sb.Append (Environment.NewLine);
138 sb.Append (StackTrace);
141 return sb.ToString ();