[Python.NET] buglet in module importing

Greg Chapman glc at well.com
Wed Feb 25 20:09:06 EST 2004

I just ran into this using the PythonNet-1.0-beta3 release.  If you start
interactive Python and do this:

>>> import CLR.System.Resources

No error is raised.  However, the import has in fact failed:

>>> from CLR.System.Threading import Thread
>>> assemblies = Thread.GetDomain().GetAssemblies()
>>> [a.FullName.split(',', 1)[0] for a in assemblies]
[u'mscorlib', u'python', u'Python.Runtime', u'e__NativeCall_Assembly',
u'System', u'System.Xml'].  

The System.Resources module is in the System.Windows.Forms assembly, but as you
can see, that assembly has not been loaded.  

I believe the problem is that the above import statement ultimately ends up in a
call to Assembly.LoadWithPartialName("System.Resources").  This fails because
there is no such assembly.  For some reason, this failure does not seem to be
raising a Python exception, though I think it should.

The workaround is to import System.Windows.Forms before importing

Greg Chapman

More information about the PythonDotNet mailing list