4

I have written code for my game that need to run a function of my python code. I am using Ironpython for my project. However, when I am trying to use C# dynamic typing to call a function in the code below, it compiles but I get the following error from the Internals:

" Assets/Scripts/WordSearchAlgorithm.cs(37,29): error CS1502: The best overloaded method match for
System.Runtime.CompilerServices.CallSite,object>>.Create(System.Runtime.CompilerServices.CallSiteBinder)' has some invalid arguments " "
Assets/Scripts/WordSearchAlgorithm.cs(37,29): error CS1503: Argument
'#1' cannot convert 'object' expression to type
'System.Runtime.CompilerServices.CallSiteBinder' " "
Assets/Scripts/WordSearchAlgorithm.cs(37,61): error CS0234: The type
or namespace name 'RuntimeBinder' does not exist in the namespace
`Microsoft.CSharp'. Are you missing an assembly reference? "
Assets/Scripts/WordSearchAlgorithm.cs(37,61): error CS1502: The best
overloaded method match for 'System.Runtime.CompilerServices.CallSite>.Create(System.Runtime.CompilerServices.CallSiteBinder)' has some invalid arguments

I think mono doesn't support this. Could you please give me a solution to help me?

static public void StartSearchAlgorithm()
{
    List < string > myList = new List < string > ()
    {
        "fxie",
         "amlo",
         "ewbx",
         "astu"
    };
    var ironPythonRuntime = Python.CreateRuntime();
    try
    {
        //Load the Iron Python file/script into the memory
        //Should be resolve at runtime
        dynamic loadIPython = ironPythonRuntime.UseFile("C:/py.py");
        //Invoke the method and print the result
        loadIPython.BoggleWords(myList, loadIPython.MakeTrie("C:/words.txt")); // here is my problem to calling function from python that unity logError
        //    Debug.Log(string.Format("dd", loadIPython.BoggleWords(myList, loadIPython.MakeTrie("C:/words.txt"))));
    }
    catch (FileNotFoundException ex)
    {}
}
0

1 Answer 1

2

Unity uses the Mono 2.0 version of .NET, which is similar to .NET 3.5. dynamic was introduced in .NET 4.0, so Unity will probably not compile.

There is the option to change Mono 2.0 sub to Mono 2.0 full in the Player Settings, but I don't know if that supports dynamic. At least you can try.

enter image description here

Sign up to request clarification or add additional context in comments.

6 Comments

I am trying to change Mono 2.0 sub to Mono 2.0 full in the Player Settings but error still exist
Then it is not supported in Mono 2.0. Also see this answer: answers.unity3d.com/questions/686244/…
Thanks Marnix for your Answering , I had seen this topic before but like code above. I want to call my Python function that without using C# dynamic typing do not work . I don't know maybe should change my coding
Can you find an IronPython library that uses .NET 3.5 maybe?
I had used IronPython 2.6 from C#4.0 , but unity had errors for its Libraries
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.