diff --git a/RedGate.AppHost.Client/Program.cs b/RedGate.AppHost.Client/Program.cs index 2fb49c1..62c7aeb 100644 --- a/RedGate.AppHost.Client/Program.cs +++ b/RedGate.AppHost.Client/Program.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; @@ -53,9 +54,22 @@ private static IOutOfProcessEntryPoint LoadChildAssembly(string assembly) { var outOfProcAssembly = Assembly.LoadFile(assembly); - var entryPoint = outOfProcAssembly.GetTypes().Single(x => x.GetInterfaces().Contains(typeof (IOutOfProcessEntryPoint))); + Type entryPoint = FindEntryPoint(outOfProcAssembly); - return (IOutOfProcessEntryPoint) Activator.CreateInstance(entryPoint); + return (IOutOfProcessEntryPoint)Activator.CreateInstance(entryPoint); + } + + private static Type FindEntryPoint(Assembly outOfProcAssembly) + { + var types = new Type[]{ }; + try + { + types = outOfProcAssembly.GetTypes(); + } catch (ReflectionTypeLoadException ex) + { + types = ex.Types.Where(x => x != null).ToArray(); + } + return types.Single(x => x.GetInterfaces().Contains(typeof(IOutOfProcessEntryPoint))); } private static void InitializeRemoting(string id, IOutOfProcessEntryPoint entryPoint)