After having setup a minimum repro case for a MSDN Forum 
(http://forums.microsoft.com/Forums/ShowPost.aspx?PostID=2735385&SiteID=1), I 
came up with a simple workaround that suits me for now...

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....

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.

So, checking is an assembly is dynamic before calling ScanAssembly does the 
trick, see the following patch :

Index: pythonnet/src/runtime/assemblymanager.cs
===================================================================
--- pythonnet/src/runtime/assemblymanager.cs    (révision 90)
+++ pythonnet/src/runtime/assemblymanager.cs    (copie de travail)
@@ -87,7 +87,12 @@
         static void AssemblyLoadHandler(Object ob, AssemblyLoadEventArgs args){
             Assembly assembly = args.LoadedAssembly;
             assemblies.Add(assembly);
-            ScanAssembly(assembly);
+            // .NET v2.0 SP1 bug workaround ; ScanAssembly called on newly 
created DynamicAssembly causes problems
+            // only scan non-dynamic assemblies...
+            if ( !(assembly is System.Reflection.Emit.AssemblyBuilder) )
+            {
+                ScanAssembly(assembly);
+            }
         }

It fixes the issue, as I'm quite new to .NET I may miss something obvious...

Any thoughts ?

Cheers,
Nicolas.
_________________________________________________
Python.NET mailing list - PythonDotNet@python.org
http://mail.python.org/mailman/listinfo/pythondotnet

Reply via email to