私は C# 開発者で、.NET フレームワークで IronPython ライブラリを使用する必要があります。Python ですべてのクラスをテストしましたが、動作していますが、C# クラスでライブラリを呼び出す方法がわかりません。
ライブラリを呼び出そうとすると、'LightException' object has no attribute
クライアント エラーが発生します。
lib、-x:Full フレーム、およびすべてのモジュールを lib フォルダーに追加しました。
Python ライブラリを呼び出すために使用している C# コードを次に示します。
Console.WriteLine("Press enter to execute the python script!");
Console.ReadLine();
var options = new Dictionary<string, object>();
options["Frames"] = true;
options["FullFrames"] = true;
//var py = Python.CreateEngine(options);
//py.SetSearchPaths(paths);
ScriptEngine engine = Python.CreateEngine(options);
ICollection<string> paths = engine.GetSearchPaths();
string dir = @"C:\Python27\Lib\";
paths.Add(dir);
string dir2 = @"C:\Python27\Lib\site-packages\";
paths.Add(dir2);
engine.SetSearchPaths(paths);
ScriptSource source = engine.CreateScriptSourceFromFile(@"C:\Users\nikunjmange\Source\Workspaces\Visage Payroll\VisagePayrollSystem\VisagePayrollSystem\synapsepayLib\synapse_pay-python-master\synapse_pay\resources\user.py");
ScriptScope scope = engine.CreateScope();
source.Execute(scope);
dynamic Calculator = scope.GetVariable("User");
dynamic calc = Calculator();
string inputCreate = "nik12@gmail.com";
string result = calc.create(inputCreate);