public static Assembly HPToolsAssemblyResolver(object sender, ResolveEventArgs args)
{
AssemblyName asmName = new AssemblyName(args.Name);
if (asmName == null)
{
return(null);
}
string assemblyName = asmName.Name;
if (assemblyName.EndsWith(".resources"))
{
return(null);
}
if (assemblyName == "HpToolsLauncher.XmlSerializers")
{
return(null);
}
string installtionPath = null;
installtionPath = Helper.getLRInstallPath();
if (installtionPath == null)
{
ConsoleWriter.WriteErrLine(string.Format(Resources.LoadRunnerNotInstalled,
System.Environment.MachineName));
Environment.Exit((int)Launcher.ExitCodeEnum.Aborted);
}
installtionPath = Path.Combine(installtionPath, "bin");
Assembly ans;
if (!File.Exists(Path.Combine(installtionPath, assemblyName + ".dll")))
{
//resource!
ConsoleWriter.WriteErrLine("cannot locate " + assemblyName + ".dll in installation directory");
Environment.Exit((int)Launcher.ExitCodeEnum.Aborted);
}
else
{
//Console.WriteLine("loading " + assemblyName + " from " + Path.Combine(installtionPath, assemblyName + ".dll"));
ans = Assembly.LoadFrom(Path.Combine(installtionPath, assemblyName + ".dll"));
AssemblyName loadedName = ans.GetName();
if (loadedName.Name == "Interop.Wlrun")
{
if (loadedName.Version.Major > 11 ||
(loadedName.Version.Major == 11 && loadedName.Version.Minor >= 52))
{
return(ans);
}
else
{
ConsoleWriter.WriteErrLine(string.Format(Resources.HPToolsAssemblyResolverWrongVersion,
Environment.MachineName));
Environment.Exit((int)Launcher.ExitCodeEnum.Aborted);
}
}
else
{
return(ans);
}
}
return(null);
}