<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.6000.16587" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV>
<DIV><FONT face=Arial size=2>After having setup a minimum repro case for a MSDN 
Forum (<A 
href="http://forums.microsoft.com/Forums/ShowPost.aspx?PostID=2735385&amp;SiteID=1">http://forums.microsoft.com/Forums/ShowPost.aspx?PostID=2735385&amp;SiteID=1</A>), 
I came up with a simple workaround that suits me for now...</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>The problems comes for the AssemblyManager, it 
seems that on dynamic Assemblies, the AssemblyLoad event is called before the 
Assembly object is properly set up, and that the GetTypes() call issued in 
ScanAssembly messes up the internal state of the newly created 
Assembly....</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>As, dynamic assemblies are empty when created, 
there's no point is scanning them - at least, this is the case of assemblies 
created by Python.Runtime.CodeGenerator and 
Python.Runtime.NativeCall.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>So, checking is an assembly is dynamic before 
calling ScanAssembly does the trick, see the following patch :</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Index: 
pythonnet/src/runtime/assemblymanager.cs<BR>===================================================================<BR>--- 
pythonnet/src/runtime/assemblymanager.cs&nbsp;&nbsp;&nbsp; (révision 90)<BR>+++ 
pythonnet/src/runtime/assemblymanager.cs&nbsp;&nbsp;&nbsp; (copie de 
travail)<BR>@@ -87,7 +87,12 
@@<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; static void 
AssemblyLoadHandler(Object ob, AssemblyLoadEventArgs 
args){<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
Assembly assembly = 
args.LoadedAssembly;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
assemblies.Add(assembly);<BR>-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
ScanAssembly(assembly);<BR>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
// .NET v2.0 SP1 bug workaround ; ScanAssembly called on newly created 
DynamicAssembly causes 
problems<BR>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
// only scan non-dynamic 
assemblies...<BR>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
if ( !(assembly is System.Reflection.Emit.AssemblyBuilder) 
)<BR>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
{<BR>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
ScanAssembly(assembly);<BR>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</FONT></DIV><FONT 
face=Arial size=2>
<DIV><BR>It fixes the issue, as I'm quite new to .NET I may miss something 
obvious...</DIV>
<DIV>&nbsp;</DIV>
<DIV>Any thoughts ?</DIV>
<DIV>&nbsp;</DIV>
<DIV>Cheers,</DIV>
<DIV>Nicolas.</FONT></DIV>
<DIV>&nbsp;</DIV></DIV></BODY></HTML>