56e30d48d163947ea052a6120d3843cc6cd6e3e5
[mono.git] / mcs / class / corlib / System / TypeLoadException.cs
1 //
2 // System.TypeLoadException
3 //
4 // Author:
5 //   Sean MacIsaac (macisaac@ximian.com)
6 //   Duncan Mak  (duncan@ximian.com)
7 //
8 // (C) 2001 Ximian, Inc.  http://www.ximian.com
9 //
10
11 using System.Globalization;
12 using System.Runtime.Serialization;
13
14 namespace System {
15
16         [Serializable]
17         public class TypeLoadException : SystemException {
18
19                 // Fields
20                 private string msg;
21                 private string type;
22
23                 private string ClassName;
24                 private string AssemblyName;
25                 private string MessageArg;
26                 private string ResourceID;
27                 
28                 // Constructors
29                 public TypeLoadException ()
30                         : base (Locale.GetText ("A type load exception has occurred."))
31                 {
32                         msg = Locale.GetText ("A type load exception has occured.");
33                 }
34
35                 public TypeLoadException (string message)
36                         : base (message)
37                 {
38                         msg = message;
39                 }
40
41                 public TypeLoadException (string message, Exception inner)
42                         : base (message, inner)
43                 {
44                         msg = message;
45                 }
46
47                 protected TypeLoadException (SerializationInfo info, StreamingContext context)
48                         : base (info, context)
49                 {
50                         if (info == null)
51                                 throw new ArgumentNullException ("info is null.");
52
53                         ClassName = info.GetString ("TypeLoadClassName");
54                         AssemblyName = info.GetString ("TypeLoadAssemblyName");
55                         MessageArg = info.GetString ("MessageArg");
56                         ResourceID = info.GetString ("ResourceID");
57                 }
58
59                 // Properties
60                 public override string Message
61                 {
62                         get { return msg; }
63                 }
64
65                 public string TypeName
66                 {
67                         get { return type; }
68                 }
69
70                 // Methods
71                 public override void GetObjectData (SerializationInfo info, StreamingContext context)
72                 {
73                         if (info == null)
74                                 throw new ArgumentNullException ("info is null.");
75
76                         base.GetObjectData (info, context);
77                         info.AddValue ("TypeLoadClassName", ClassName, typeof (string)); 
78                         info.AddValue ("TypeLoadAssemblyName", AssemblyName, typeof (string));
79                         info.AddValue ("TypeLoadMessageArg", MessageArg, typeof (string));
80                         info.AddValue ("TypeLoadResourceID", ResourceID);
81                 }
82         }
83 }