I am attempting to pass an IronPython function into the following C#
functions, which I import into IronPython:

        public static Func<object> getFunc1(params Func<object> [] functions) {
                return functions[0];
        }
        
        public static Func<object> getFunc2(IList<Func<object>> functions) {
                return functions[0];
        }
        
The first works fine:

python>>> Myro.getFunc1(test1)
<System.Func`1[[System.Object, mscorlib, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089]] object at
0x000000000000002B [System.Func`1[System.Object]]>
Ok

But the second gives the following error:

python>>> Myro.getFunc2([test1])
Traceback (most recent call last):
  File "<string>", line 1, in <module>
TypeError: Unable to cast object of type
'IronPython.Runtime.PythonFunction' to type
'System.Func`1[System.Object]'.

What am I missing in the second case that prevents the cast?

Thanks for any pointers,

-Doug
_______________________________________________
Ironpython-users mailing list
Ironpython-users@python.org
http://mail.python.org/mailman/listinfo/ironpython-users

Reply via email to