2003-07-24 Gonzalo Paniagua Javier <gonzalo@ximian.com>
[mono.git] / mcs / class / corlib / System / TypeLoadException.cs
index 499b3ff798ce7f953a4017e5106df7ab385a0a59..01c844b19cc4e0fa4a08c2d499f67036512a56a8 100644 (file)
@@ -19,55 +19,62 @@ namespace System {
                // Fields
                private string msg;
                private string type;
-               
+
                 // Constructors
                public TypeLoadException ()
                        : base (Locale.GetText ("A type load exception has occurred."))
                {
-                       msg = Locale.GetText ("A type load exception has occured.");
                }
 
                public TypeLoadException (string message)
                        : base (message)
                {
-                       msg = message;
                }
 
                public TypeLoadException (string message, Exception inner)
                        : base (message, inner)
                {
-                       msg = message;
                }
 
-               public TypeLoadException (SerializationInfo info,
-                                         StreamingContext context)
+               protected TypeLoadException (SerializationInfo info, StreamingContext context)
                        : base (info, context)
                {
+                       if (info == null)
+                               throw new ArgumentNullException ("info is null.");
+
+                       type = info.GetString ("type");
                }
 
                // Properties
-               public override string Message
-               {
-                       get { return msg; }
+               public override string Message {
+                       get {
+                               if (type == null)
+                                       return base.Message;
+
+                               if (msg == null)
+                                       msg = "Cannot load type '" + type + "'";
+
+                               return msg;
+                       }
                }
 
-               public string TypeName
-               {
-                       get { return type; }
+               public string TypeName {
+                       get { 
+                               if (type == null)
+                                       return "";
+
+                               return type;
+                       }
                }
 
                // Methods
-               //
-               // It seems like this object serializes more fields than those described.
-               // Those fields are TypeLoadClassName, TypeLoadAssemblyName,
-               // TypeLoadMessageArg and TypeLoadResourceID.
-               //
-               [MonoTODO] 
                public override void GetObjectData (SerializationInfo info, StreamingContext context)
                {
                        if (info == null)
                                throw new ArgumentNullException ("info is null.");
+
                        base.GetObjectData (info, context);
+                       info.AddValue ("type", type, typeof (string)); 
                }
        }
 }