diff --git a/ChangeLog b/ChangeLog index dc6624731..bfffcc9b6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-06-17 Mike Kestner + + * glib/GType.cs (LookupType): traversed referenced assemblies to + find types in currently unloaded assemblies. Fixes #400595. + 2008-06-16 Andrés G. Aragoneses * atk/Object.custom: diff --git a/glib/GType.cs b/glib/GType.cs index 4787f7e86..cb7ed7f83 100755 --- a/glib/GType.cs +++ b/glib/GType.cs @@ -151,6 +151,23 @@ namespace GLib { // cctor already calls g_type_init. } + static Type FindTypeInReferences (string type_name, Assembly asm, Hashtable visited) + { + if (visited.Contains (asm)) + return null; + + visited [asm] = asm; + Type result = asm.GetType (type_name); + if (result == null) + foreach (AssemblyName ref_name in asm.GetReferencedAssemblies ()) { + Assembly ref_asm = Assembly.Load (ref_name); + result = FindTypeInReferences (type_name, ref_asm, visited); + if (result != null) + break; + } + return result; + } + public static Type LookupType (IntPtr typeid) { if (types.Contains (typeid)) @@ -159,12 +176,22 @@ namespace GLib { string native_name = Marshaller.Utf8PtrToString (g_type_name (typeid)); string type_name = GetQualifiedName (native_name); Type result = null; - foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies ()) { + Assembly[] assemblies = (Assembly[]) AppDomain.CurrentDomain.GetAssemblies ().Clone (); + foreach (Assembly asm in assemblies) { result = asm.GetType (type_name); if (result != null) break; } + if (result == null) { + Hashtable visited = new Hashtable (); + foreach (Assembly asm in assemblies) { + result = FindTypeInReferences (type_name, asm, visited); + if (result != null) + break; + } + } + Register (new GType (typeid), result); return result; }