1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| private static Assembly OnResolveAssembly(object sender, ResolveEventArgs args)
{
Assembly executingAssembly = Assembly.GetExecutingAssembly();
AssemblyName assemblyName = new AssemblyName(args.Name);
string path = assemblyName.Name + ".dll";
if (assemblyName.CultureInfo.Equals(CultureInfo.InvariantCulture) == false)
{
path = String.Format(@"{0}\{1}", assemblyName.CultureInfo, path);
}
File.AppendAllText(@"C:\log.tago.txt", Environment.NewLine);
File.AppendAllText(@"C:\log.tago.txt", Environment.NewLine + "Args.Name = " + args.Name);
File.AppendAllText(@"C:\log.tago.txt", Environment.NewLine + "AssemblyName = " + assemblyName);
File.AppendAllText(@"C:\log.tago.txt", Environment.NewLine + "AssemblyName.CultureInfo = " + assemblyName.CultureInfo.DisplayName);
File.AppendAllText(@"C:\log.tago.txt", Environment.NewLine + "Path = " + path);
using (Stream stream = executingAssembly.GetManifestResourceStream(path))
{
if (stream == null)
{
File.AppendAllText(@"C:\log.tago.txt", Environment.NewLine + "Resultat = INTROUVABLE");
return null;
}
else
{
File.AppendAllText(@"C:\log.tago.txt", Environment.NewLine + "Resultat = OK");
}
byte[] assemblyRawBytes = new byte[stream.Length];
stream.Read(assemblyRawBytes, 0, assemblyRawBytes.Length);
return Assembly.Load(assemblyRawBytes);
}
} |
Partager