Update Bootstrap.cs

pull/1/head
Ogoun 5 years ago
parent be3ccca524
commit 7f0d63cf2b

@ -96,31 +96,47 @@ namespace ZeroLevel
{ {
try try
{ {
Log.Info($"[Bootstrap] Resolve assembly '{args.Name}'"); Log.Info($"[Bootstrap] Resolve assembly '{args.Name}' {args.Name}");
if (args.Name.StartsWith("Newtonsoft.Json", StringComparison.Ordinal)) if (args.Name.StartsWith("Newtonsoft.Json", StringComparison.Ordinal))
{ {
return Assembly.LoadFile(Path.Combine(Configuration.BaseDirectory, "Newtonsoft.Json.dll")); return Assembly.LoadFile(Path.Combine(Configuration.BaseDirectory, "Newtonsoft.Json.dll"));
} }
var candidates = Directory.GetFiles(Path.Combine(Configuration.BaseDirectory), "*.dll", SearchOption.TopDirectoryOnly)?.ToList(); string name = args.Name.Split(',')[0];
if (candidates != null && candidates.Any()) if (name.EndsWith(".resources")) return null;
{
int max = -1; int index = -1; foreach (string file in Directory.
for (int i = 0; i < candidates.Count; i++) GetFiles(Path.Combine(Configuration.BaseDirectory), "*.dll", SearchOption.TopDirectoryOnly))
{ {
if (args.Name.IndexOf(candidates[i]) >= 0) if (file.IndexOf(name, StringComparison.OrdinalIgnoreCase) >= 0)
{ {
if (max < candidates[i].Length) Log.Info($"[Bootstrap] Resolve assembly '{args.Name}' found '{file}'");
{ return Assembly.LoadFile(file);
max = candidates[i].Length; }
index = i; }
}
} //var candidates = Directory.GetFiles(Path.Combine(Configuration.BaseDirectory), name + ".dll", SearchOption.TopDirectoryOnly)
} // ?.Select(s => Path.GetFileNameWithoutExtension(s))
if (index != -1) // ?.ToList();
{ //if (candidates != null && candidates.Any())
return Assembly.LoadFile(candidates[index]); //{
} // int max = -1; int index = -1;
} // for (int i = 0; i < candidates.Count; i++)
// {
// if (args.Name.IndexOf(candidates[i], StringComparison.OrdinalIgnoreCase) >= 0)
// {
// if (max < candidates[i].Length)
// {
// max = candidates[i].Length;
// index = i;
// }
// }
// }
// if (index != -1)
// {
// return Assembly.LoadFile(Path.Combine(Configuration.BaseDirectory, candidates[index] + ".dll"));
// }
//}
} }
catch (Exception ex) catch (Exception ex)
{ {

Loading…
Cancel
Save

Powered by TurnKey Linux.