[Python.NET] Invoking a C# method with a python list

Mohamed Koubaa mohamed.koubaa at ansys.com
Mon Jul 30 12:43:26 EDT 2018


Hello,

I am using the 2.3 release branch.

I have C# code like this:
    public class A {
        public A() {...}
    }

    public class B {
        public B() {...}
        public static void Func(IEnumerable<A> input){
        }
    }

I want to pass in a python list to Func but get this error:
>>> b=B()
>>> b.Func([A(), A()])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: No method matches given arguments

I tried both IEnumerable and IList in the signature of 'Func'.  I know that
I can import System and create some .NET collection type and it works well.

Did I miss anything?  Is this usage pattern within the design goals of
pythonnet?  I assume this would have to be fixed in MethodBinder but I
wanted to try asking here first.

Thanks!
Mohamed Koubaa
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pythondotnet/attachments/20180730/0877e1e4/attachment.html>


More information about the PythonDotNet mailing list