Browse Source

Fix, SerializationInfo.GetValue might throw an error

svn path=/trunk/mcs/; revision=68055
Miguel de Icaza 19 years ago
parent
commit
eebf4087dd
1 changed files with 6 additions and 1 deletions
  1. 6 1
      mcs/class/corlib/System.Collections/Hashtable.cs

+ 6 - 1
mcs/class/corlib/System.Collections/Hashtable.cs

@@ -575,7 +575,12 @@ namespace System.Collections {
 			loadFactor = (float) serializationInfo.GetValue ("LoadFactor", typeof(float));
 			modificationCount = (int) serializationInfo.GetValue ("Version", typeof(int));
 #if NET_2_0
-			equalityComparer = (IEqualityComparer) serializationInfo.GetValue ("KeyComparer", typeof (object));
+			try {
+				equalityComparer = (IEqualityComparer) serializationInfo.GetValue ("KeyComparer", typeof (object));
+			} catch {
+				// If not found, try to get "Comparer"
+			}
+			
 			if (equalityComparer == null)
 				comparerRef = (IComparer) serializationInfo.GetValue ("Comparer", typeof (object));
 #else