[IronPython] IronPython to JavaScript

xkrja kristian.jaksch at gmail.com
Mon Jan 12 13:43:10 CET 2009

I'm trying to call javascript from IronPython (via Silverlight 2) but I can'
get it to work properly. I looked at this example:


It's explained very clearly but when I try to run my code I get a System

SystemError: Object reference not set to an instance of an object.

I just inserted the lines of code found on the example page in my IronPyton

event = ScriptableEvent()

# This must also be registered
HtmlPage.RegisterScriptableObject("event", event)

args = ScriptableEventArgs()
args.val = 'some string'
event.OnEvent(args) #This gives me a System Error

I create a C# .dll as explained in the example and add a reference to it.
The source is below:

using System;
using System.Windows.Browser;

namespace Scriptable

    public class ScriptableForString
        public string method(string value)
        { return this._method(value); }

        public virtual string _method(string value)
        { return "override me"; }

    public class ScriptableEvent
        public event EventHandler Event;

        public virtual void OnEvent(ScriptableEventArgs e)
            Event(this, e);

    public class ScriptableEventArgs : EventArgs
        private string _val;

        public string val
            get { return _val; }
            set { _val = value; }

Can anyone explain what I'm doing wrong? 

Thanks for any help!

View this message in context: http://www.nabble.com/IronPython-to-JavaScript-tp21413681p21413681.html
Sent from the IronPython mailing list archive at Nabble.com.

More information about the Ironpython-users mailing list