diff --git a/source/Components/AvalonDock/Layout/LayoutRoot.cs b/source/Components/AvalonDock/Layout/LayoutRoot.cs index ba81f75c..ed905d49 100644 --- a/source/Components/AvalonDock/Layout/LayoutRoot.cs +++ b/source/Components/AvalonDock/Layout/LayoutRoot.cs @@ -12,6 +12,7 @@ This program is provided to you under the terms of the Microsoft Public using System.Collections.ObjectModel; using System.Diagnostics; using System.Linq; +using System.Reflection; using System.Text; using System.Windows.Controls; using System.Windows.Markup; @@ -653,9 +654,19 @@ void IXmlSerializable.WriteXml(XmlWriter writer) internal static Type FindType(string name) { - foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) - foreach (var type in assembly.GetTypes()) - if (type.Name.Equals(name)) return type; + var avalonAssembly = Assembly.GetAssembly(typeof(LayoutRoot)); + + foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies().OrderBy(a => a != avalonAssembly)) + try + { + foreach (var type in assembly.GetTypes()) + if (type.Name.Equals(name)) + return type; + } + catch (ReflectionTypeLoadException) + { + } + return null; } @@ -995,4 +1006,4 @@ void DumpElement(ILayoutElement element, StringBuilder indent, int childID, bool #endregion Diagnostic tools } -} \ No newline at end of file +}