I have been following the guidance given on this other post:
Assigning an IronPython method to a C# delegate
This post also references another resource on the darker corners of IronPython that has some useful information:
http://www.voidspace.org.uk/ironpython/dark-corners.shtml
I am trying to invoke an IronPython method from C# as a delegate. My latest attempt looks as follows (using System.Action):
IronPython Code:
delegate = Action[String](self.testErrorDelegate);
#csharp library method call
csharp_library.InvokeAction(delegate);
...
@unittest.skip("dev skipping")
def testErrorDelegate(self,message):
print "error delegate"
print message;
csharp library code:
public void InvokeAction(Action<string> listener)
{
Console.WriteLine("BEFORE INVOKE");
listener("DO SOMETHING");
Console.WriteLine("AFTER INVOKE");
}
My problem is I get no output from the python testErrorDelegate when running this. No runtime errors either. I see the C# Console.WriteLine statements but "DO SOMETHING" is never printed.
Any idea on what I could be doing wrong here?
I have also tried doing the same approach casting directly to a C# delegate from the python method. I saw the same behavior using that approach, i.e. verification of C# method call, but not return call to python code via delegate.
I am using IronPython 2.7.1 (ipy.exe).