Questions tagged [python.net]

Python for .NET is a package that gives Python programmers nearly seamless integration with the .NET Common Language Runtime (CLR) and Mono. Pythonnet provides a powerful application scripting tool for .NET developers. Using this package you can script .NET applications or build entire applications in Python, using .NET services and components written in any language that targets the CLR (C#, VB.NET, F#, C++/CLI) and CPython.

Python for .NET is a package that gives Python programmers nearly seamless integration with the .NET Common Language Runtime (CLR) and Mono. Pythonnet provides a powerful application scripting tool for .NET developers. Using this package you can script .NET applications or build entire applications in Python, using .NET services and components written in any language that targets the CLR (C#, VB.NET, F#, C++/CLI) and CPython.

https://pythonnet.github.io/

578 questions
0
votes
0 answers

Pythonnet net6 c# pyd file is blocked after imported by Py.Import()

1.I have a '.pyd' file called apriori_function.pyd 2.I Import this file by Py.import() 3.The file is blocked The file is blocked I have tried follow ways, but not resolved: 1.o.Dispose() 2.PythonEngine.Shutdown()
0
votes
0 answers

Python,net in C# development. How to pass value to the method and receive the return value?

Am trying to run python script file using ASP.NET C#. Using Python.net since IronPython does not support libraries I use. Is there any Python.net resources or example projects that I may possible use? I want to pass the id from C# to the end() and…
Dababy
  • 3
  • 3
0
votes
0 answers

pythonnet Exception: System.NullReferenceException: Object reference not set to an instance of an object

I'm trying to learn Python.NET module, but at the very beginning I face some problems. I'm trying to execute this simple code: import clr clr.AddReference("System") clr.AddReference("System.Drawing") clr.AddReference("System.Windows.Forms") import…
Itay Dvash
  • 40
  • 9
0
votes
0 answers

Pythonnet error: Could not load file that has been referenced

I am using pythonnet to import C# dll files. (IDE: Visual Studio Code) I have added the references and the codes do not give an error, but when I try to use one of the classes from the references it gives this error: System.IO.FileNotFoundException:…
0
votes
0 answers

Python.Net Winforms Application & PyQt5 combined

Is it possible to run a Winforms Apllication within a PyQt5 main application? I have a main python PyQt5 application, but need to integrate an additonal part from a Net Winforms App. The problem is the event loop of the Winforms app. Is there any…
0
votes
0 answers

Calling Python code(using multiprocessing) in window form application cause fork and create child processes

I am working on a window form application and I need to call some code from python. In python multiprocessing module is used which causes a fork in window form or spawns multiple windows. I am posting here a demo code for more understanding. Please…
0
votes
0 answers

How to implement ILogger in python

I am trying to create a concrete implementation of ILogger in python using the build in python logger. However, when I try to implement the ILogger interface, I'm getting the exception Method 'Log' in type 'Microsoft.Extensions.Logging.PyLogger'…
0
votes
0 answers

Python.NET event handling when events are fired from external .NET application

I'm trying to instantiate a .NET object in Python runtime, subscribe to events being fired from an external .NET application via that API object (i.e. the event isn't being fired by Python), and handle the events within python to synchronize the…
Carter Canedy
  • 73
  • 1
  • 9
0
votes
1 answer

Accessing Contents of "System.Reflection.Pointer"? (Python 3.10)

I'm calling a set of C# functions from a Python 3.10 script via the clr module from the PythonNet library. One of those functions returns a pointer of type System.Reflection.Pointer, that points to an array of float values. I'm quite a bit confused…
Runsva
  • 365
  • 1
  • 7
0
votes
1 answer

passing parameter (with ref) and string array into a .net function with clr pythonnet

I have this function in a dll that i imported via clr in python with asNetArray function that i found somewhere in the net. public static double DrawdownTable(ref System.Array resDrawdown, ref System.Array resPeak, ref System.Array resThrough, ref…
0
votes
2 answers

Converting Python List to .NET IEnumerable?

I'm attempting to call a C# function from a Python script, via the clr module from the PythonNet library. One of the arguments that this C# function takes is of the type System.Collections.Generic.IEnumerable. Simply supplying a list of the required…
Runsva
  • 365
  • 1
  • 7
0
votes
1 answer

Python.net "GIL" lifetime and multiple instances

My desktop app uses IronPython to perform various scripting functions, but we're under pressure to support Numpy (which isn't possible with IP), so I'm currently looking into Python.Net instead, but I'm a bit unclear on how to manage the lifetimes…
Andrew Stephens
  • 9,413
  • 6
  • 76
  • 152
0
votes
0 answers

ModuleNotFoundError: No module named 'System'

I'm working on an EXE file crypter in python 3.11.1 and I cannot seem to get the System.Reflection import working. I've tried pythonnet and clr, but it just doesn't recognize 'System.' I've tried to make sure pythonnet and clr are not conflicting,…
0
votes
0 answers

Install latest version of mono-complete on docker

RUN apt-get update apt-get install -y mono-complete I have added this on the docker file, but I get this error /usr/local/lib/python3.8/site-packages/clr_loader/mono.py:180: UserWarning: Hosting Mono versions before v6.12 is known to be…
user19540656
0
votes
0 answers

Pythonnet cannot convert object to target type why?

using pythonnet during runtime i got an error. I tried using AsManagedObject(Type t) and as () functions but showing runtime error.