In general, when we need to load an external assembly (for example, to load a third-party control), we need to use system to avoid a third-party control program vulnerability or want to securely access the assembly. security. policy. create an evidence to restrict the permission to access this assembly.
Code
Static void main (string [] ARGs)
{
Object [] hostevidences = {New Zone (system. Security. securityzone. Internet )};
Evidence internetevices = new evices (hostevidences, null );
Appdomain APP = appdomain. createdomain ("first ");
App. executeassembly (appdomain. currentdomain. friendlyname, interneteviname );
Console. Read ();
}
Generally, we use the appdomain. createdomain () method to create an application domain and grant the corresponding permissions. When we don't need it, we can uninstall it to improve program efficiency.
How can I configure the application domain attribute? Here we need to use the appdomainsetup class.
Static void main (string [] ARGs)
{
Appdomainsetup ads = new appdomainsetup ();
Ads. applicationbase = "file: //" + system. environment. currentdirectory;
Ads. disallowbindingredirects = false;
Ads. disallowcodedownload = true;
Ads. configurationfile = appdomain. currentdomain. setupinformation. configurationfile;
Appdomain d = appdomain. createdomain ("newdomain", null, ADS );
Console. Read ();
}