DLR 需要哪些强制性PermissionSet
项目才能正常运行?
我们在沙盒脚本环境中启用了 DLR。但是一些类似下面的代码......
dynamic foo = someobject
foo.FooBar();
...只会导致抛出一个相当模糊且“未完成”的异常,如下所示:
System.Security.SecurityException: Request failed.
at CallSite.Target(Closure , CallSite , Object )
at System.Dynamic.UpdateDelegates.UpdateAndExecuteVoid1[T0](CallSite site, T0 arg0)
at AcmeCorp.AcmeRocket.Workflow.Scripting.Assemblies.WorkflowScriptImplementation.Test()
at AcmeCorp.AcmeRocket.Workflow.Scripting.Assemblies.WorkflowScriptImplementation.__action_activity_4397110c5d7141a6802a070d3b942b77()
--- End of inner exception stack trace ---
at AcmeCorp.AcmeRocket.Workflow.Scripting.WorkflowScriptProxy.Invoke(String method_name)
at AcmeCorp.AcmeRocket.Workflow.Execution.Executors.ActionActivityExecutor.Execute(WorkflowInstance wi, ActionActivity activity)
at AcmeCorp.AcmeRocket.Workflow.Execution.ActivityExecutorBase.Execute(WorkflowInstance wi, Activity activity)
at AcmeCorp.AcmeRocket.Workflow.Execution.WorkflowExecutor.ExecuteActivity(WorkflowInstance wi, Activity activity)
at AcmeCorp.AcmeRocket.Workflow.Execution.WorkflowExecutor.Execute(WorkflowInstance wi, Nullable`1 branch_index)
通常SecurityException
's 包含大量详细信息,详细说明了哪些权限导致它失败,但在这种情况下,我们没有得到那个 - 非常烦人。
PS:如果我在我们的沙箱临时授予 a 的情况下运行相同的测试,PermissionSet(PermissionState.Unrestricted)
那么问题就会消失。但显然,我们确实希望将其锁定为 DLR 所需的特定权限集。
PPS:当前(失败)PermissionSet 创建如下:
var ps = new PermissionSet(PermissionState.None);
ps.AddPermission(new SecurityPermission(SecurityPermissionFlag.Execution));
ps.AddPermission(new ReflectionPermission(ReflectionPermissionFlag.RestrictedMemberAccess));
谢谢。