[IronPython] Compiling into a DLL with pyc.py and then calling the class

Srivatsn Narayanan srivatsn at microsoft.com
Tue Aug 26 11:15:24 PDT 2008


You are missing an import after adding the reference. This should work:

clr.AddReference("test")
from test import test
t = test()

There was also a bug with passing references with relative path (fixed now). If it blows up for you, try passing in the fully qualified assembly name.

-----Original Message-----
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of hellosticky
Sent: Tuesday, August 26, 2008 11:07 AM
To: IronPython
Subject: [IronPython] Compiling into a DLL with pyc.py and then calling the class

Hi, I'm new to IronPython. I have the following test.py:

from System import *
from System.Collections.Generic import *
from System.Text import *
from PublicDomain import *

class test:
        def foo(self):
                return GlobalConstants.EarthEquatorialRadiusInKilometers

PublicDomain is a package from here: http://www.codeplex.com/PublicDomain

I compile this python file into a DLL with:

ipy.exe pyc.py /out:test /target:dll /r:..\publicdomain\PublicDomain.dll test.py

Everything looks good in ildasm. Then I load up ipy.exe:

>ipy
IronPython 2.0 Beta (2.0.0.4000) on .NET 2.0.50727.1433
Type "help", "copyright", "credits" or "license" for more information.
>>> import clr
>>> clr.AddReference("test")
>>> t = test()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'test' is not defined

Any ideas what I'm doing wrong?

Thanks!

_______________________________________________
Users mailing list
Users at lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com



More information about the Users mailing list