[Python.NET] Errors with Python.Net 2.0 SP 1
Feihong Hsu
hsu.feihong at yahoo.com
Fri Feb 15 16:10:57 CET 2008
Yes! That did the trick.
Thanks so much for tracking the problem down!
- Feihong
--- Nicolas Lelong <nico_ml at mgdesign.fr> wrote:
> 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 at python.org
> http://mail.python.org/mailman/listinfo/pythondotnet
____________________________________________________________________________________
Looking for last minute shopping deals?
Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping
More information about the PythonDotNet
mailing list