[IronPython] Making A Windows Form App
jimhug at exchange.microsoft.com
Thu Jul 7 02:23:55 CEST 2005
We clearly need a better design than the current sys.LoadAssembly* methods. For one thing, we shouldn't really be adding these to the existing sys module but putting new methods like this in a new IronPython module. As you point out, we should also do a better job of making this as invisible to the user as possible.
In IronPython-0.6, a much larger number of assemblies were automatically searched for - including the two shown below. This meant that this particular program could run without any of this nonsense. The problem here was that this just delayed the issue of people learning about this issue and made things even more confusing when they wanted to use an assembly that wasn't in the known list. I decided that at this stage it was better to raise this issue front-and-center so that people would be aware of it and hopefully get quickly familiar with it. The other reason I wanted to make this more explicit was in the hopes that it would spur discussion about better ways of solving the problem.
I'm certain that sys.LoadAssembly* is not what will ship with IronPython-1.0. Here are a few possible options in no particular order.
1. Guess the assembly based on the path, i.e. import System.Drawing will try to load "System.Drawing". This would be great if it was a naming convention that was consistently followed, but alas it is a rule that is so consistently broken I'm doubtful of the benefits.
2. Add a config file to specific a large set of default known assemblies and have the user extend this with their own. This ties scripts and config files together in a deeper way than I'd prefer.
3. Extend import, i.e. import System.Drawing from System.Drawing. Of course, the most obvious ways to do this are a change to the Python language.
4. Search some well-known directories to come up with a list of known assemblies and their types and then load assemblies strictly as needed for imports. This would add many seconds to start-up time unless this information is cached and caches are their own source of trouble. FYI - This is closest to what Jython does.
5. I'm sure there are other good ideas out there...
There's a whole separate question as to whether or not any loading by partial name is too dangerous even as explicit as it is today, see here:
Thanks - Jim
From: users-ironpython.com-bounces at lists.ironpython.com [mailto:users-ironpython.com-bounces at lists.ironpython.com] On Behalf Of Keith J. Farmer
Sent: Wednesday, July 06, 2005 1:36 PM
To: Discussion of IronPython
Subject: RE: [IronPython] Making A Windows Form App
Out of curiosity, would it be possible to get IronPython to make a best-guess attempt at automatically loading an appropriate assembly, if it discovers that it doesn't know the namespace?
This could alleviate the problems people have with remembering sys.LoadAssemblyByName.
From: users-ironpython.com-bounces at lists.ironpython.com on behalf of Martin Maly
Sent: Wed 7/6/2005 1:13 PM
More information about the Ironpython-users