I have been using Python.net to run a Python script from a C# WPF app. C# code injects necessary C# objects by using “PyScope.Set(variable name, object.ToPython)()” like so:
You can find a full working example of this in the ObjectRefence quick start you can find in <your-alternet-studio-installation-location>\Demo\Scripter.Python\QuickStarts\ObjectReference
I was able to register objects. My next question is how to register C# enums and types? For example, they can be used as parameters of Python functions.
I have one more question (hopefully the final one). I got an exception message box, saying “TypeError. No method matches given arguments for MyMethod: (<class ‘list’>)”, when I ran my Python script that calls a C# object method that has a List parameter as shown below:
public void MyMethod(List<SomeClass> list) {...}
The list that is passed to the C# method is created in Python just like usual - i.e, list = [].
DAP Debugging works for a regular scripts executed as separate processes by running python.exe. If you would like to embed python in your application and link C# application objects to it, you can use AlterNET Scripter/Debugger for Python. For a complete debugging example, you can refer to a demo project which is installed by default to “C:\Users\Public\Documents\AlterNET Software\AlterNET Studio v.8\Demo\Scripter.Python.Wpf\QuickStarts\Debugger\DebuggerIntegration” directory.
If you would like to embed python in your application and link C# application objects to it,
That depends. If the user could install their desired python packages in the embedded folder, the answer is yes. How would the user do that?
Otherwise, no. I would like the user to install desired Python and its packages, as long as the Pythonnet.dll that is integrated into the Alternet Studio supports that specific version of Python.
The “DebuggerIntegration” sample you referred to uses embedded Python. I have already verified that referencing C# objects worked fine there.
Would you be able to create another sample “DebuggerIntegrationFullPythonWithObjectReference”?