<div>(I think) I can repro this with the following code:</div>
<div>&nbsp;</div>
<div>static void Main() {&nbsp;</div>
<div>&nbsp;&nbsp;&nbsp; AppDomainSetup info = new AppDomainSetup();<br>&nbsp;&nbsp;&nbsp; info.ApplicationBase = System.Environment.CurrentDirectory;<br>&nbsp;&nbsp;&nbsp; info.ApplicationName = &quot;Test&quot;;</div>
<div>&nbsp;&nbsp;&nbsp; Evidence evidence = new Evidence();<br>&nbsp;&nbsp;&nbsp; evidence.AddHost(new Zone(SecurityZone.Internet));</div>
<div>&nbsp;&nbsp;&nbsp; AppDomain newDomain = AppDomain.CreateDomain(&quot;test&quot;, evidence, info);</div>
<div>&nbsp;&nbsp;&nbsp; ScriptRuntime runtime = ScriptRuntime.Create(newDomain);<br>&nbsp;}</div>
<div><br>System.MethodAccessException was unhandled<br>&nbsp; Message=&quot;RemoteRuntimeFactory..ctor(Microsoft.Scripting.Hosting.ScriptRuntimeSetup)&quot;<br>&nbsp; Source=&quot;mscorlib&quot;<br>&nbsp; StackTrace:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at System.Reflection.MethodBase.PerformSecurityCheck(Object obj, RuntimeMethodHandle method, IntPtr parent, UInt32 invocationFlags)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at System.Activator.CreateInstance(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityInfo, StackCrawlMark&amp; stackMark)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at System.Activator.CreateInstance(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityInfo)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at System.AppDomain.CreateInstance(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityAttributes)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at System.AppDomain.CreateInstanceAndUnwrap(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityAttributes)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at System.AppDomain.CreateInstanceAndUnwrap(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityAttributes)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at Microsoft.Scripting.Hosting.ScriptRuntime.RemoteRuntimeFactory.CreateRuntime(AppDomain domain, ScriptRuntimeSetup setup)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at Microsoft.Scripting.Hosting.ScriptRuntime.CreateInternal(AppDomain domain, ScriptRuntimeSetup setup)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at Microsoft.Scripting.Hosting.ScriptRuntime.Create(AppDomain domain)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at ConsoleApplication7.Program.Main() in C:\Users\CurtH\Documents\Visual Studio 2008\Projects\ConsoleApplication1\ConsoleApplication7\Program.cs:line 27<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at System.Threading.ThreadHelper.ThreadStart_Context(Object state)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at System.Threading.ThreadHelper.ThreadStart()<br>
&nbsp; InnerException: <br><br>&nbsp;</div>
<div class="gmail_quote">On Tue, Apr 1, 2008 at 1:33 PM, Dino Viehland &lt;<a href="mailto:dinov@exchange.microsoft.com">dinov@exchange.microsoft.com</a>&gt; wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div lang="EN-US" vlink="purple" link="blue">
<div>
<p><span style="FONT-SIZE: 11pt; COLOR: #1f497d">Can you give us the full stack trace of the exception that gets thrown and also what version of the CLR are you running against?</span></p>
<p><span style="FONT-SIZE: 11pt; COLOR: #1f497d">&nbsp;</span></p>
<p><span style="FONT-SIZE: 11pt; COLOR: #1f497d">It may be the case that partial trust will require the latest and greatest patch of .NET as there have been some changes to enable reflection / reflection emit to work better in partial trust.&nbsp; But it could also be a DLR or IronPython bug when running in partial trust on the desktop CLR.</span></p>

<p><span style="FONT-SIZE: 11pt; COLOR: #1f497d">&nbsp;</span></p>
<div>
<div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: #b5c4df 1pt solid; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; BORDER-LEFT: medium none; PADDING-TOP: 3pt; BORDER-BOTTOM: medium none">
<p><b><span style="FONT-SIZE: 10pt">From:</span></b><span style="FONT-SIZE: 10pt"> <a href="mailto:users-bounces@lists.ironpython.com" target="_blank">users-bounces@lists.ironpython.com</a> [mailto:<a href="mailto:users-bounces@lists.ironpython.com" target="_blank">users-bounces@lists.ironpython.com</a>] <b>On Behalf Of </b>Sho List<br>
<b>Sent:</b> Tuesday, April 01, 2008 12:43 PM<br><b>To:</b> <a href="mailto:users@lists.ironpython.com" target="_blank">users@lists.ironpython.com</a><br><b>Subject:</b> [IronPython] Restricting IronPython/DLR in a Sandbox?</span></p>
</div></div>
<p>&nbsp;</p>
<p style="MARGIN-BOTTOM: 12pt"><span style="FONT-SIZE: 10pt">Hello IronPythoners,<br>&nbsp;<br>I am using the IronPython 2 Beta 1 on .Net 2.0.<br>&nbsp;<br>My goal is to create a restricted sandbox for scripts to run in using the DLR. I have searched high and low and have not found a solution utilizing the latest python beta release and DLR.&nbsp;It would seem this is something that should be straightforward to accomplish as the DLR&#39;s ScriptRuntime.Create takes an AppDomain as an overload. And indeed, my Python engine and runtime are loaded in the remote AppDomain, however I can only get it to work when the AppDomain has FullTrust permissions. Anything lower (say Intranet Zone and the like)&nbsp;and it throws a Method Access Exceptions on the ScriptRuntime.Create method.<br>
&nbsp;<br>I have tried creating the AppDomain like so:<br>AppDomain.CreateDomain(name, defaultEvidence, appDomainSetup, defaultPermissions, TrustedAssemblies.ToArray)<br>&nbsp;<br>Where:<br>name is the name<br>defaultEvidence is the evidence for the restricted zone<br>
appDomainSetup sets the BaseDirectory<br>defaultPermissions is the permission set of the restricted zone<br>TrustedAssemblies is a list containing references to &quot;Microsoft.Scripting&quot;, &quot;IronPython&quot;, &quot;IronPython.Modules&quot;<br>
&nbsp;<br>Using any zone other than MyComputer results in the exception. I am not stuck on getting a permission set from a predefined zone, I have tried creating permissions sets other ways with the same result. Using zones seems easier for illustration.<br>
&nbsp;<br>I need IronPython scripts to be run in a fairly constrained environment. No file&nbsp;IO, no loading assemblies. Basically, just the ability for the user to interact with the Hosting apps object model with some basic .Net library functions like String etc.<br>
&nbsp;<br>Thanks!</span></p>
<div style="TEXT-ALIGN: center" align="center"><span style="FONT-SIZE: 10pt">
<hr align="center" width="100%" size="2">
</span></div>
<p><span style="FONT-SIZE: 10pt">Pack up or back up–use SkyDrive to transfer files or keep extra copies. <a>Learn how.</a></span></p></div></div><br>_______________________________________________<br>Users mailing list<br>
<a href="mailto:Users@lists.ironpython.com">Users@lists.ironpython.com</a><br><a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com" target="_blank">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a><br>
<br></blockquote></div><br>