IronRuby - Wrong number of arguments

60 Views Asked by At

I just started using IronRuby. This is my test class:

class Program
    {
        static void Main(string[] args)
        {
            var path = @"C:\Users\frays\Desktop\test.rb";
            var engine = Ruby.CreateEngine();
            var scope = engine.Runtime.CreateScope();

            scope.SetVariable("sendNext", new Action<string>(SendNext));

            engine.ExecuteFile(path, scope);

            Console.Read();
        }

        private static void SendNext(string text)
        {
            Console.WriteLine(text);
        }
    }

And this is my test script:

sendNext 'heyyy'

However, when trying to run the program it throws an exception saying wrong number of arguments (1 for 0), even though the method definitely takes a string as an argument.

1

There are 1 best solutions below

0
Max On

This says that it is not possible Calling IronRuby from C# with a delegate but you can just call the invoke method.

sendNext.Invoke( 'heyyy')