Antaris/RazorEngine — Issue #32: SecurityException when used IsolatedTemplateService
Author: yarblade
Created: 2012-02-27 07:20:19+00:00
State: open

When I use IsolatedTemplateService with "sandbox" I get a SecurityException with description "Request failed" and no details that would help me understand the problem.
I create a sandbox with the following code:

private AppDomain CreateAppDomain()
{
var permissionSet = new PermissionSet(null);
permissionSet.AddPermission(new SecurityPermission(PermissionState.Unrestricted));
permissionSet.AddPermission(new ReflectionPermission(PermissionState.Unrestricted));
var assemblies = AppDomain.CurrentDomain.GetAssemblies().First( x => x.GetName().Name == "RazorEngine" ).Evidence.GetHostEvidence();

return AppDomain.CreateDomain("RazorTestHost", AppDomain.CurrentDomain.Evidence, AppDomain.CurrentDomain.SetupInformation, permissionSet, assemblies);
}

If I use IsolatedTemplateService with default AppDomainFactory It works fine, but I need some restrictions on executable code.