<div>Interestingly, the code works correctly when the flag -X:SaveAssemblies is used.&nbsp; It also doesn&#39;t happen if the same code exists in an external assembly that&#39;s called by IronPython.&nbsp; This suggests that the issue is in the dynamic code generation in the DLR and is not directly related to any kind of CAS issues, but I haven&#39;t yet been able to find any code changes that could explain the different behavior.<br>
</div>
<div class="gmail_quote">On Fri, May 2, 2008 at 5:59 PM, Curt Hagenlocher &lt;<a href="mailto:curt@hagenlocher.org">curt@hagenlocher.org</a>&gt; wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div>The following code works for me under B1, but throws an exception under B2:</div>
<div>&nbsp;</div>
<div><font face="courier new,monospace">import clr<br>import System<br>name = System.Reflection.AssemblyName()<br>name.Name = &#39;Test&#39;<br>assemblyBuilder = System.AppDomain.CurrentDomain.DefineDynamicAssembly(name, System.Reflection.Emit.AssemblyBuilderAccess.Run)<br>
</font></div>
<div>&nbsp;</div>
<div>The stack trace is, of course, entirely inside the CLR.</div>
<div>&nbsp;</div>
<div>Traceback (most recent call last):<br>&nbsp; File &quot;&lt;stdin&gt;&quot;, line 1, in &lt;module&gt;<br>&nbsp; File &quot;mscorlib&quot;, line unknown, in DefineDynamicAssembly<br>&nbsp; File &quot;mscorlib&quot;, line unknown, in InternalDefineDynamicAssembly<br>
&nbsp; File &quot;mscorlib&quot;, line unknown, in nCreateDynamicAssembly<br>&nbsp; File &quot;mscorlib&quot;, line unknown, in CheckGrantSetHelper<br>SystemError: Object reference not set to an instance of an object.</div>
<div>&nbsp;</div>
<div>Unfortunately, nCreateDynamicAssembly is an InternalCall, so I can&#39;t see exactly what it&#39;s doing.&nbsp; The only object reference in CheckGrantSetHelper is to a PermissionSet, presumably one of the three that are passed to nCreateDynamicAssembly.&nbsp; Based on the methods higher in the stack, I expect that all three PermissionSets passed to nCreateDynamicAssembly are null, but this would have been true under B1 as well.</div>

<div>&nbsp;</div>
<div>Have there been security-related changes made that could cause this problem?</div>
<div>&nbsp;</div><font color="#888888">
<div>--</div>
<div>Curt Hagenlocher</div>
<div><a href="mailto:curt@hagenlocher.org" target="_blank">curt@hagenlocher.org</a></div></font></blockquote></div><br>