Enabling App Domain Policy to run an executable
From: Jason Collum (jcollum_at_bear.com)
Date: 08/30/04
- Next message: Russ: "RE: UNC Path access is denied"
- Previous message: David W. Griffin: "Re: NUnit and StrongnameIdentityPermission"
- Next in thread: Shawn Farkas: "RE: Enabling App Domain Policy to run an executable"
- Reply: Shawn Farkas: "RE: Enabling App Domain Policy to run an executable"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Mon, 30 Aug 2004 12:51:26 -0500
I have looked over the internet and found some code to create an application
domain policy, create a permission set based on "LocalIntranet", add
additional permissions, union membership conditions with the permission set,
and try to execute another application. My code can be found below. Even
after giving the FileIOPermission unrestricted access to the app domain
policy, the other application is still throwing the securityexception
because the FileIOPermission failed. Can someone please shed some light on
why this is happenning and maybe help me figure out how to get it to work?
Code Example:
namespace ApplicationLauncher
{
class Launch
{
static void Main (string[] args)
{
if (args.Length < 1)
{
System.Console.WriteLine("Usage: Launch <assembly>");
return;
}
string fileName = args[0];
System.AppDomain ad = System.AppDomain.CreateDomain("AppLaunch");
System.Security.Policy.PolicyLevel domainPolicy =
System.Security.Policy.PolicyLevel.CreateAppDomainLevel();
System.Security.Policy.AllMembershipCondition allCodeMC = new
System.Security.Policy.AllMembershipCondition();
System.Security.PermissionSet internetPermissionSet =
domainPolicy.GetNamedPermissionSet("LocalIntranet");
System.Security.Policy.PolicyStatement internetPolicyStatement = new
System.Security.Policy.PolicyStatement(internetPermissionSet);
System.Security.Policy.CodeGroup allCodeInternetCG = new
System.Security.Policy.UnionCodeGroup(allCodeMC, internetPolicyStatement);
domainPolicy.RootCodeGroup = allCodeInternetCG;
ad.SetAppDomainPolicy(domainPolicy);
string[] newArgs = new string[args.Length-1];
System.Array.Copy(args, 1, newArgs, 0, args.Length-1);
ad.ExecuteAssembly(fileName, null, newArgs);
}
}
}
- Next message: Russ: "RE: UNC Path access is denied"
- Previous message: David W. Griffin: "Re: NUnit and StrongnameIdentityPermission"
- Next in thread: Shawn Farkas: "RE: Enabling App Domain Policy to run an executable"
- Reply: Shawn Farkas: "RE: Enabling App Domain Policy to run an executable"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]