Я пытаюсь создать простой приветственный мир, чтобы проверить встраивание IronPython в C #, но, похоже, не могу решить эту проблему.
Это мой файл C #;
using System;
using IronPython.Hosting;
using Microsoft.Scripting;
using Microsoft.Scripting.Hosting;
using System.IO;
public class dynamic_demo
{
static void Main()
{
var ipy = Python.CreateRuntime();
dynamic test = ipy.UseFile(@"../../Test.py");
test.Simple();
}
}
А это класс питона;
import sys
def Simple():
print 'Hello from Python'
print "Call Dir(): "
print dir()
print "Print the Path: "
print sys.path
Моя целевая платформа .NET - 4.0, и я использую IronPython 2.6 ..
Я получаю 2 ошибки при запуске, эта из файла с именем «CSC»; Ошибка 5 Отсутствует обязательный член компилятора
'Microsoft.CSharp.RuntimeBinder.Binder.InvokeMember' C: \ Users \ Tolga \ documents \ Visual Studio 2012 \ Projects \ WindowsFormsApplication1 \ consoleTest \ CSC consoleTest
Другой - из файла C #, который я создал
Ошибка 6 Не удалось найти один или несколько типов, необходимых для компиляции динамического выражения. Вам не хватает ссылки? C: \ Users \ Tolga \ documents \ Visual Studio 2012 \ Projects \ WindowsFormsApplication1 \ consoleTest \ Program.cs 17 9 consoleTest
Вот результат сборки
1>------ Build started: Project: consoleTest, Configuration: Debug Any CPU ------
1>CSC : warning CS1685: The predefined type 'System.Runtime.CompilerServices.CallSite' is defined in multiple assemblies in the global alias; using definition from 'c:\Program Files (x86)\IronPython 2.6\Microsoft.Scripting.Core.dll'
1>CSC : warning CS1685: The predefined type 'System.Runtime.CompilerServices.CallSite' is defined in multiple assemblies in the global alias; using definition from 'c:\Program Files (x86)\IronPython 2.6\Microsoft.Scripting.Core.dll'
1>CSC : warning CS1685: The predefined type 'System.Runtime.CompilerServices.CallSiteBinder' is defined in multiple assemblies in the global alias; using definition from 'c:\Program Files (x86)\IronPython 2.6\Microsoft.Scripting.Core.dll'
1>CSC : warning CS1685: The predefined type 'System.Runtime.CompilerServices.ExtensionAttribute' is defined in multiple assemblies in the global alias; using definition from 'c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\mscorlib.dll'
1>CSC : error CS0656: Missing compiler required member 'Microsoft.CSharp.RuntimeBinder.Binder.InvokeMember'
1>C:\Users\Tolga\documents\visual studio 2012\Projects\WindowsFormsApplication1\consoleTest\Program.cs(17,9,17,20): error CS1969: One or more types required to compile a dynamic expression cannot be found. Are you missing a reference?
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========