I am trying to create a worker app domain in C# in VS 2010 to try out the simple sandboxing technique as mentioned here: http://blogs.msdn.com/shawnfa/archive/2005/08/08/449050.aspx
My code inside the function Main looks like this:
PermissionSet pset = new PermissionSet(PermissionState.None);
pset.AddPermission(new SecurityPermission(SecurityPermissionFlag.Execution));
AppDomainSetup domaininfo = new AppDomainSetup();
domaininfo.ApplicationBase = @"D:\MyPrograms\WindowsFormsApplication1\Debug";
// create the sandboxed domain
AppDomain sandbox = AppDomain.CreateDomain(
"Sandboxed Domain",
AppDomain.CurrentDomain.Evidence,
domaininfo,
pset);
sandbox.ExecuteAssembly("WindowsFormsApplication1.exe");
When i execute this code, I am getting an exception - "Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed."
Anyone knows why this is? It will be helpful if any body post the correct code here.
Thanks, Niranjan