Hi Dan, The parameterless Action is actually defined in System.Core.dll so you need to reference that. The crash ofcourse needs to be fixed. There is already a bug on that - http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=19133
-----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Dan Eloff Sent: Thursday, November 20, 2008 1:21 PM To: Discussion of IronPython Subject: [IronPython] More fun with delegates This is not a blocker, but In RC1 and the 2.1 branch of 43741 the following happens: >>> import clr >>> clr.AddReference('PresentationFramework') >>> clr.AddReference('WindowsBase') >>> from System.Windows import Window >>> d = Window().Dispatcher >>> def echo(x): ... print x ... >>> d.BeginInvoke(echo, 2) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: expected Delegate, got function >>> d.BeginInvoke(lambda: echo(2)) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: expected Delegate, got function However, in Silverlight, for some odd reason, it works fine. >>> from System import Action >>> def foo(): pass >>> Action(foo) Will crash the interpreter/browser. But this will work: >>> def foo(i): ... pass ... >>> from System import Action >>> Action[int](foo) <System.Action`1[[System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] object at 0x000000000000002B [System.Action`1[System.Int32]]> So a workaround for now is to do: >>> d.BeginInvoke(Action[object](echo), 2) -Dan _______________________________________________ Users mailing list [email protected] http://lists.ironpython.com/listinfo.cgi/users-ironpython.com _______________________________________________ Users mailing list [email protected] http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
