[IronPython] clr.AddRefernce* woes

Shawn Wheatley swheatley at gmail.com
Wed Mar 1 23:09:45 CET 2006


Hi All!

I just got back from PyCon, where I got to see Martin Maly's talk on
IronPython. I see that Beta 3 is causing quite a bit of problems. I
seem to be having more problems than most, but that may be due to how
I set up my environment. Could someone help me?

Here's what I did:
1) Downloaded the latest IP beta and unpacked to C:\Program
Files\IronPython-1-Beta3
2) Added C:\Program Files\IronPython-1-Beta3 to my path
3) Created a batch file to launch IronPythonConsole:
"C:\Program Files\IronPython-1-Beta3\IronPythonConsole" %1 %2 %3 %4 %5
%6 %7 %8 %9
4) When trying to do any import that involves a reference, I get an error:

C:\Program Files\IronPython-1-Beta3>ipc
IronPython 1.0.2237 (Beta) on .NET 2.0.50727.42
Copyright (c) Microsoft Corporation. All rights reserved.
>>> import clr
>>> import System
>>> clr.AddReference(System.Reflection.Assembly.Load('System.Xml'))
Traceback (most recent call last):
  File , line 0, in input##76
IOError: Could not load file or assembly 'System.Xml' or one of its dependencies
. The system cannot find the file specified.
>>> clr.AddReference(System.Reflection.Assembly.LoadFrom('System.Xml'))
Traceback (most recent call last):
  File , line 0, in input##94
IOError: Could not load file or assembly 'file:///C:\Program Files\IronPython-1-
Beta3\System.Xml' or one of its dependencies. The system cannot find the file sp
ecified.
>>> clr.AddReference(System.Reflection.Assembly.LoadWithPartialName('System.Xml'
))

Process is terminated due to StackOverflowException.

C:\Program Files\IronPython-1-Beta3>

If anybody could help me out I'd really appreciate it.

Thanks,
Shawn Wheatley

On 2/24/06, Dan Shechter <dans at houmus.org> wrote:
> Worked like a charm! Thanks!
>
> Just one note, if you want to make this completely "generic" You need to
> >>>clr.AddAssembly(System.Reflection.Assembly.LoadFrom(
> System.Environment.CurrentDirectory +
> System.IO.Path.DirectorySeparatorChar +
> "MYDLL.DLL"))
>
>         Danke!
>
> -----Original Message-----
> From: Stanislas Pinte [mailto:stan at phidani.be]
> Sent: Friday, February 24, 2006 12:02
> To: Discussion of IronPython; Dan Shechter
> Cc: 'Discussion of IronPython'
> Subject: Re: [IronPython] clr.AddRefernce* woes
>
> Selon Dan Shechter <dans at houmus.org>:
>
> > Perhaps I wasn't being clear:
> > I have been able to use your suggested workaround to load .NET "Core"
> > assemblies such as System.Xml etc.
>
> I am able to do that with the following code: (don't know if it is the
> recommended way)
>
> ClrModule.AddAssembly(Assembly.LoadFrom(currentDirName +
> Path.DirectorySeparatorChar +
> "MyPackage.dll"));
>
> --> all namespaces inside MyPackage.dll are then magically available in the
> python engine.
>
> >
> > My problem is that I don't have a working workaround for Assemblies like
> > mapack.dll or my own assemblies which reside in some other directory (like
> > the IronPython tutorial directory).
> >
> > -----Original Message-----
> > From: users-bounces at lists.ironpython.com
> > [mailto:users-bounces at lists.ironpython.com] On Behalf Of Dino Viehland
> > Sent: Friday, February 24, 2006 04:08
> > To: Discussion of IronPython
> > Subject: Re: [IronPython] clr.AddRefernce* woes
> >
> > There were a couple of bugs w/ assembly loading in beta 3.
> >
> > As a work around you should be able to do:
> >
> > import System
> > clr.AddReference(System.Reflection.Assembly.Load('System.Xml'))
> >
> > clr.AddReference(System.Reflection.Assembly.LoadFrom('System.Xml'))
> >
> >
> clr.AddReference(System.Reflection.Assembly.LoadWithPartialName('System.Xml'
> > ))
> >
> >
> > Obviously we'll have it fixed in beta 4.
> >
> >
> > Do you want to help develop Dynamic languages on CLR?
> >
> (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F
> > 0-45DF-8B78-DC1B43134038)
> >
> > -----Original Message-----
> > From: users-bounces at lists.ironpython.com
> > [mailto:users-bounces at lists.ironpython.com] On Behalf Of Dan Shechter
> > Sent: Thursday, February 23, 2006 4:19 PM
> > To: users at lists.ironpython.com
> > Subject: [IronPython] clr.AddRefernce* woes
> >
> > Hi,
> > I've just installed beta 3 drop but I can't use clr.AddReference to
> anything
> > that isn't part of .NET 2.0 core libraries.
> > I'm trying to load a .NET 2.0 compiled assembly. "PERWAPI.dll", I have a
> > test.exe console c# program
> > which does invoke methods and instantiate classes defined within that DLL.
> > I'm also having problems with the tutorial "demo" using mapack.dll., I've
> > provided a transcript below:
> > ---------------------------------------- CUT HERE
> > ----------------------------
> > >>> import clr
> > >>> clr.AddReference("System.XML")
> > - Crashed
> >
> > >>> import clr
> > >>> clr.AddReferenceByPartialName("System.XML")
> > - works
> >
> > >>> clr.AddReferenceByPartialName("Mapack")
> > Traceback (most recent call last):
> >   File , line 0, in input##152
> >   File , line 0, in AddReferenceByPartialName##81
> > RuntimeError: Could not add reference to assembly Mapack
> >
> > >>> clr.Path
> > []
> >
> > >>> clr.Path.append(System.Environment.CurrentDirectory)
> >
> > >>> clr.Path
> > ['C:\\Development\\IronPython\\Tutorial']
> >
> > >>> clr.AddReferenceByPartialName("Mapack")
> >  - Crashed
> > ---------------------------------------- CUT HERE
> > ----------------------------
> >
> > Naturally the same happens for PERWAPI.dll (which I'm really interested in
> > getting to work) and naturally,
> > Both .DLLs (PERWAPI.DLL & MAPACK.DLL) are in the '
> > C:\Development\IronPython\Tutorial'' on my machine...
> >
> > Any ideas?
> >
> >
> >
> > _______________________________________________
> > users mailing list
> > users at lists.ironpython.com
> > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
> > _______________________________________________
> > users mailing list
> > users at lists.ironpython.com
> > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
> >
> >
> > _______________________________________________
> > users mailing list
> > users at lists.ironpython.com
> > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
> >
> >
> >
>
>
>
>
>
>
>
>
> _______________________________________________
> users mailing list
> users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>



More information about the Ironpython-users mailing list