// Create the evidence for the assembly Evidence evidence = new Evidence(); evidence.AddHost(new Url("http://www.example.com")); // Create the assembly StrongName strongName = new StrongName( new StrongNamePublicKeyBlob("E8E1C8F04BE8CBE3"), "Assembly1", new Version("1.0.0.0") ); Assembly assembly = Assembly.Load(strongName, evidence);
Assembly assembly; // Assume assembly was loaded somewhere // Verify the evidence of the assembly Evidence evidence = assembly.Evidence; if (evidence != null) { Url url = evidence.GetHost(typeof(Url)) as Url; if (url != null && url.Value == "http://www.example.com") { // Evidence is valid } }This example retrieves the evidence from an assembly that was loaded somewhere else. It then checks if the evidence includes a URL, and if the URL is the expected value. If the evidence is valid, the code can be granted additional permissions. Package library: System.Security.Permissions (included in .NET Framework)