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 35 36 37 38
|
//Clé publique provenant de resultat.txt qui est devenu obsolete vu
// que j'ai changé la signature de ma dll
byte[] PluginKey =
{ 0, 36, 0, 0, 4, 128, 0, 0, 148, 0, 0, 0, 6, 2, 0, 0, 0, 36, 0, 0, 82, 83, 65, 49, 0, 4, 0, 0, 1, 0, 1, 0, 193, 117, 109, 4, 41, 249, 57, 19, 51, 208, 4, 61, 184, 22, 199, 134, 148, 30, 20, 104, 76, 138, 9, 139, 70, 39, 149, 132, 234, 41, 72, 63, 104, 53, 154, 18, 99, 207, 225, 118, 91, 31, 49, 227, 242, 40, 141, 253, 240, 16, 94, 33, 226, 189, 114, 62, 60, 58, 189, 160, 102, 140, 73, 238, 9, 33, 171, 179, 164, 118, 236, 103, 156, 11, 85, 241, 245, 92, 125, 177, 65, 52, 215, 54, 65, 93, 43, 68, 180, 172, 61, 232, 236, 50, 184, 86, 81, 232, 225, 33, 227, 112, 144, 52, 202, 238, 53, 20, 53, 110, 93, 240, 222, 187, 118, 160, 212, 17, 47, 129, 106, 163, 108, 80, 55, 153, 137, 226 };
StrongNamePublicKeyBlob blob =
new StrongNamePublicKeyBlob(PluginKey);
Version version = new Version("1.0.0.0");
StrongName sn = new StrongName(blob, "Plugin", version);
Evidence evidence = new Evidence();
evidence.AddAssembly(sn);
Assembly ass = null;
try
{
Console.WriteLine("Charge l'assembly");
if (!File.Exists("Plugin.dll"))
Console.WriteLine("Plugin absent");
//Je m'attends à une exception, vu que la clé publique n'est
// pas la bonne ! pourtant ca passe.
ass = Assembly.LoadFrom("Plugin.dll", evidence);
//ici par contre isKeyValid vaudra false comme prévu
bool isKeyValid = ass != null &&
ass.GetName() != null &&
ass.GetName().GetPublicKey() != null &&
PluginKey.SequenceEqual(ass.GetName().GetPublicKey());
}
catch (Exception ex)
{
Console.WriteLine("Piti probleme :");
Console.WriteLine(ex);
}
Console.ReadLine(); |
Partager