protected virtual void LoadAssembly(string assembly, bool soft)
{
TypeManager typeManager = program.TypeManager;
Assembly a;
string totalLog = "";
try {
/*
char[] path_chars = { '/', '\\', '.' };
if (assembly.IndexOfAny(path_chars) != -1) {
*/
char[] path_chars = { '/', '\\' };
if (assembly.IndexOfAny(path_chars) != -1 ||
assembly.ToLower().EndsWith(".dll")) {
a = Assembly.LoadFrom(assembly);
} else {
a = Assembly.Load(assembly);
}
typeManager.AddAssembly(a);
} catch (FileNotFoundException){
foreach (string dir in linkPaths){
string full_path = Path.Combine (dir, assembly);
if (!assembly.EndsWith (".dll"))
full_path += ".dll";
try {
a = Assembly.LoadFrom (full_path);
typeManager.AddAssembly (a);
return;
} catch (FileNotFoundException ff) {
totalLog += ff.FusionLog;
continue;
}
}
if (!soft) {
Console.Error.WriteLine("cannot find assembly `{0}'",
assembly);
Console.Error.WriteLine("Log: {0}\n", totalLog);
Environment.Exit(1);
}
} catch (BadImageFormatException f) {
Console.Error.WriteLine("cannot load assembly " +
"(bad file format): {0}",
f.FusionLog);
Environment.Exit(1);
} catch (FileLoadException f){
Console.Error.WriteLine("cannot load assembly {0}: {1}",
assembly, f.FusionLog);
Environment.Exit(1);
}
}