Which code segment should you use?

You are loading a new assembly into an application.
You need to override the default evidence for the assembly.
You require the common language runtime (CLR) to grant the assembly a permission set, as if the assembly were loaded from the local intranet zone.
You need to build the evidence collection.
Which code segment should you use?

You are loading a new assembly into an application.
You need to override the default evidence for the assembly.
You require the common language runtime (CLR) to grant the assembly a permission set, as if the assembly were loaded from the local intranet zone.
You need to build the evidence collection.
Which code segment should you use?

A.
Evidence evidence = new Evidence(Assembly.GetExecutingAssembly().Evidence);

B.
Evidence evidence = new Evidence();
evidence.AddAssembly(new Zone(SecurityZone.Intranet));

C.
Evidence evidence = new Evidence();
evidence.AddHost(new Zone(SecurityZone.Intranet));

D.
Evidence evidence = new Evidence(AppDomain.CurrentDomain.Evidence);

Explanation:
Use the evidence.AddHost method to add Zone evidence.
A simply gets the evidence of the Executing Assembly and assigns it to a new object, the question explicitly wants Intranet zone evidence.
B Adds assembly evidence, the question asks for host evidence because it is concerned with where the assembly was loaded from.
D does not create an Evidence object with Intranet zone evidence.



Leave a Reply 1

Your email address will not be published. Required fields are marked *


networkmanagers

networkmanagers

Correct answer is C