Handle the case where not all types of an assembly can be loaded
authorMaarten Bosmans <mkbosmans@gmail.com>
Sat, 26 Dec 2009 11:23:48 +0000 (12:23 +0100)
committerSebastian Dröge <sebastian.droege@collabora.co.uk>
Mon, 4 Jan 2010 09:01:23 +0000 (10:01 +0100)
gstreamer-sharp/Application.cs

index 08ca68b9aa55b7369e4e1c93e2365c5a42863dad..b365a746559834fdf9b59a0f4a597d4bb17fbada 100644 (file)
@@ -88,9 +88,14 @@ namespace Gst {
       // Add types with GTypeNameAttribute in TypeCache
       if (result) {
         AssemblyTypesInCache[asm.GetHashCode ()] = true;
-        Type[] ts = asm.GetTypes ();
+        Type[] ts;
+        try {
+          ts = asm.GetTypes ();
+        } catch (ReflectionTypeLoadException e) {
+          ts = e.Types;
+        }
         foreach (Type t in ts) {
-          if (t.IsDefined (typeof (GTypeNameAttribute), false)) {
+          if (t != null && t.IsDefined (typeof (GTypeNameAttribute), false)) {
             GTypeNameAttribute gattr = (GTypeNameAttribute) Attribute.GetCustomAttribute (t, typeof (GTypeNameAttribute), false);
             TypeCache[gattr.TypeName] = t;
           }