[IronPython] Running IronPython code from C#

Frédéric Cadier f.cadier at free.fr
Wed Jul 12 16:03:40 CEST 2006


I had something working using IronPython.Runtime.OldClass and
IronPython.Runtime.OldInstance, but I don't even understand what i've
done...

First, my IP script "ClassIP.py", defining a small class :

    class MyClass:
        def __init__ (self, text):
            self.text = text

        def test(self):
            return "Test " + self.text

And then a form with one TextBox in C# :

        public Form1()
        {
            InitializeComponent();

            new ClassIP().Initialize();
           
            IronPython.Runtime.OldInstance current =
(IronPython.Runtime.OldInstance)
               
((IronPython.Runtime.OldClass)ClassIP.MyClass).Call("from C# !");

            IronPython.Runtime.Method currentTest =
(IronPython.Runtime.Method)current.__class__.__dict__["test"];

            textBox1.Text = (string) currentTest.Call(current);
        }

Is this something meaningful for you ?

Frédéric Cadier

Sanghyeon Seo a écrit :
> 2006/7/12, Frédéric Cadier <f.cadier at free.fr>:
>   
>> I hope I won't be too annoying with a newbie question... but I'm
>> wondering how to run IP code from C# : I would for example define a
>> class MyClass in myclass.py, and want to instanciate it from some C# code.
>>     
>
> I believe this (defining CLS type in IronPython) is currently not
> possible, and it isn't planned for 1.0. That doesn't mean it won't be
> possible forever though.
>
> Seo Sanghyeon
> _______________________________________________
> users mailing list
> users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
>
>
>   
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20060712/9634d25a/attachment.html>


More information about the Ironpython-users mailing list