[IronPython] IronPython to JavaScript

Jimmy Schementi Jimmy.Schementi at microsoft.com
Sun Mar 1 17:03:42 CET 2009

Kristian wrote: 
> Just curios... Has anyone had time to look at my sample yet?

Yes, and sorry for the horrifically late reply ...


source is here:

There was a few small changes I made to Michael's code:

1. The Python code used to load the C# assembly will fail, since there's no namespace defined as Scriptable. It should be change to:

import ScriptableForString

... and "Scriptable.dll" doesn't need to be added to the AppManifest.xaml, just needs to be present in the XAP. I use clr.AddReferenceToFile because clr.AddReference or clr.AddReferenceByName can fail depending on whether or not Microsoft.Scripting.Silverlight.dll is signed (which can differ if you get the bits from codeplex or build them yourself from github), because you didn't give the fully-qualified assembly name.

2. The SomeClass class needs to take new_string as a parameter, instead of "string"

3. There are both "some_class" and "someClass" variables, but there are intended to mean the same thing. So I changed them all to "someClass".

4. Calling event.OnEvent(args) in top-level Python code can run before JavaScript has a chance to hook the event, so either an error will happen, or nothing. It's strange because it executes onload of the Silverlight control, but sounds like that happens before the start script has a chance to finish. In my demo I trigger the event from a link.

5. http://jimmy.schementi.com/silverlight/scriptable/csharp/scriptable.cs MSDN documentation said that events need to be marked with ScriptableMemberAttribute, rather than ScriptableMember. I don't think I makes a difference ...

More information about the Ironpython-users mailing list