2002-06-27 Martin Baulig <martin@gnome.org>
[mono.git] / mcs / class / corlib / System / BadImageFormatException.cs
1 // System.BadImageFormatException
2 //
3 // Sean MacIsaac (macisaac@ximian.com)
4 // Duncan Mak (duncan@ximian.com)
5 //
6 // (C) 2001 Ximian, Inc.
7
8 using System.Globalization;
9 using System.Runtime.Serialization;
10
11 namespace System
12 {
13         [Serializable]
14         public class BadImageFormatException : SystemException
15         {
16                 // Fields
17                 private string msg; // we need this because System.Exception's message is private.
18                 private Exception inner;
19                 private string fileName;
20                 private string fusionLog;
21                 
22                 // Constructors
23                 public BadImageFormatException ()
24                         : base (Locale.GetText ("Invalid file image."))
25                 {
26                         msg = "Invalid file image.";
27                 }
28                 
29                 public BadImageFormatException (string message)
30                         : base (message)
31                 {
32                         msg = message;
33                 }
34
35                 protected BadImageFormatException (SerializationInfo info, StreamingContext context)
36                         : base (info, context)
37                 {
38                         fileName = info.GetString ("BadImageFormat_FileName");
39                         fusionLog = info.GetString ("BadImageFormat_FusionLog");
40                 }
41
42                 public BadImageFormatException (string message, Exception inner)
43                         : base (message, inner)
44                 {
45                         msg = message;
46                         this.inner = inner;
47                 }
48
49                 public BadImageFormatException (string message, string fileName)
50                         : base (message)
51                 {
52                         msg = message;
53                         this.fileName = fileName;
54                 }
55
56                 public BadImageFormatException (string message, string fileName, Exception inner)
57                         : base (message, inner)
58                 {
59                         msg = message;
60                         this.inner = inner;
61                         this.fileName = fileName;
62                 }
63                     
64                 // Properties
65                 public override string Message
66                 {
67                         get { return Locale.GetText (msg); }
68                 }
69
70                 public string FileName
71                 {
72                         get { return fileName; }
73                 }
74                                 
75                 public string FusionLog
76                 {
77                         get { return fusionLog; }
78                 }
79
80                 // Methods
81                 public override void GetObjectData (SerializationInfo info, StreamingContext context)
82                 {
83                         base.GetObjectData (info, context);
84                         info.AddValue ("BadImageFormat_FileName", fileName);
85                         info.AddValue ("BadImageFormat_FusionLog", fusionLog);
86                 }
87
88                 public override string ToString ()
89                 {
90                         return inner.ToString();
91                 }
92         }
93 }