private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) { Assembly assembly = null; if (args.Name.StartsWith("@#")) { var fileDll = args.Name.Substring(2); assembly = Assembly.LoadFrom(Path.GetFullPath(fileDll)); } else { if (ServiceTypesCrossDomain != null) { if (ServiceTypesCrossDomain.ContainsKey(args.Name)) { assembly = ServiceTypesCrossDomain[args.Name]; } else { assembly = ServiceTypesCrossDomain .Where(asm => asm.Key.Split(',')[0].Equals(args.Name)) .Select(asm => asm.Value).FirstOrDefault(); } if (assembly == null && ServiceTypes != null && ServiceTypes.ContainsKey(args.Name)) { assembly = ServiceTypes[args.Name]; } } } return(assembly); }