Merge pull request #876 from knocte/master
[mono.git] / mcs / class / System / System.ComponentModel / WarningException.cs
index d615867bf40137f05f1c2fc896f82fed0aa390b8..e524884d84ef669541298f7cf168df127a8ce764 100644 (file)
@@ -32,9 +32,7 @@ using System.Security.Permissions;
 
 namespace System.ComponentModel {
 
-#if NET_2_0
        [Serializable]
-#endif
        public class WarningException : SystemException
        {
                private string helpUrl;
@@ -58,7 +56,6 @@ namespace System.ComponentModel {
                        this.helpTopic = helpTopic;
                }
 
-#if NET_2_0
                public WarningException () 
                        : base (Locale.GetText ("Warning"))
                {
@@ -72,8 +69,15 @@ namespace System.ComponentModel {
                protected WarningException (SerializationInfo info, StreamingContext context)
                        : base (info, context)
                {
-                       helpTopic = info.GetString ("HelpTopic");
-                       helpUrl = info.GetString ("HelpUrl");
+                       try {
+                               helpTopic = info.GetString ("helpTopic");
+                               helpUrl = info.GetString ("helpUrl");
+                       }
+                       catch (SerializationException) {
+                               //For compliance with previously serialized version:
+                               helpTopic = info.GetString ("HelpTopic");
+                               helpUrl = info.GetString ("HelpUrl");
+                       }
                }
 
                [SecurityPermission (SecurityAction.Demand, SerializationFormatter = true)]
@@ -82,11 +86,10 @@ namespace System.ComponentModel {
                        if (info == null)
                                throw new ArgumentNullException ("info");
 
-                       info.AddValue ("HelpTopic", helpTopic);
-                       info.AddValue ("HelpUrl", helpUrl);
                        base.GetObjectData (info, context);
+                       info.AddValue ("helpTopic", helpTopic);
+                       info.AddValue ("helpUrl", helpUrl);
                }
-#endif
 
                public string HelpTopic {
                        get {