XmlFormatterDeserializer: handle ReflectionTypeLoadExceptions better
authorRolf Bjarne Kvinge <RKvinge@novell.com>
Fri, 10 Sep 2010 09:04:10 +0000 (11:04 +0200)
committerRolf Bjarne Kvinge <RKvinge@novell.com>
Fri, 10 Sep 2010 10:44:35 +0000 (12:44 +0200)
mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/XmlFormatterDeserializer.cs

index 4c6fdd903bea1a0131fde65297a6d35a5b4080a3..105ff7b1ffd189ab76fe3467f825dc04e0d32072 100644 (file)
@@ -195,7 +195,21 @@ namespace System.Runtime.Serialization
                        string clrns = ns.StartsWith (dnsb, StringComparison.Ordinal) ?  ns.Substring (dnsb.Length) : ns;
 
                        foreach (var ass in AppDomain.CurrentDomain.GetAssemblies ()) {
-                               foreach (var t in ass.GetTypes ()) {
+                               Type [] types;
+
+#if MOONLIGHT
+                               try  {
+                                       types = ass.GetTypes ();
+                               } catch (System.Reflection.ReflectionTypeLoadException rtle) {
+                                       types = rtle.Types;
+                               }
+#else
+                               types = ass.GetTypes ();
+#endif
+                               if (types == null)
+                                       continue;
+
+                               foreach (var t in types) {
                                        // there can be null entries or exception throw to access the attribute - 
                                        // at least when some referenced assemblies could not be loaded (affects moonlight)
                                        if (t == null)