is there a way to setup an AppDomain's permissions such that the code running inside cannot kill the process that launched it ?
More precisely suppose I have an AppDomain appDomain, I would like to do something like
try
{
appDomain.ExecuteAssembly("someAssembly.exe");
}catch(SomeForbiddenActionException e){
Console.WriteLine("someAssembly tried to perform some forbidden action")
}
Suppose someAssembly.exe executes the following code:
static void Main(){
Process.GetCurrentProcess().Kill();
}
For the moment, if I run the code above, the whole application exits, which I would like to avoid at all cost, I would like the call to Process.GetCurrentProcess().Kill(); to raise an exception because it is forbidden. I tried to find some way of setting up the Evidence and/or PermissionSet during the setup of the app domain to prevent that but without success:
http://msdn.microsoft.com/en-us/library/bb763046%28v=vs.110%29.aspx
did not give me any clue on how to achieve my goal.
appDomain.ProcessExit is just a chance to call some code when the process is exiting already => not a good option
Any help or clues are very welcome, thanks !