[IronPython] Exception Handling in Silverlight 2

Michael Foord fuzzyman at voidspace.org.uk
Wed Mar 12 01:21:28 CET 2008

Hello guys,

I'm seeing some oddness in exception handling in asynchronous callbacks 
(including handlers attached to HTML events).

If I have the following code for example which raises an exception in a 
'click handler' on a xaml animation:

canvas = XamlReader.Load(xaml)
storyboard = canvas.FindName('Example')
storyboard.AutoReverse = True

def OnClick(sender, event):
    print 'before'
    x = None
        x = int('hi')
    except Exception, e:
        print 'oops', e
        x = 3
    print 'after', x
canvas.MouseLeftButtonDown += OnClick

When I click I see the 'before' and 'after' prints (I have diverted 
stdout) - but the exception handling code never seems to be executed.


More information about the Ironpython-users mailing list