C# .NET windows form example with python calls
See original GitHub issueI would like to ask that would it be possible to have an example .NET winform application which imports some python module, (ie numpy) and makes some call from it? I could not realy find such anywhere, and my trial fails right at the begining with
An unhandled exception of type ‘System.ArgumentNullException’ occurred in mscorlib.dll
Additional information: Value cannot be null.
Here is my code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Python.Runtime;
public partial class frmMain : Form
{
public frmMain()
{
InitializeComponent();
PythonEngine.Initialize(); //<- Error occurs here.
}
}
Error details:

Issue Analytics
- State:
- Created 7 years ago
- Comments:10 (4 by maintainers)
Top Results From Across the Web
c# - Executing Python Script from Windows Forms .NET
The basic idea of my project is a desktop applicaton and the overall logic would be to read from a couple of selected...
Read more >How to Build Windows Forms Applications in Python | Pt. 1
In thise series, we will build a Windows Form application using ... NET API Browser Link: https://docs.microsoft.com/en-us/dotnet/api/?view= ...
Read more >Calling Python from C#: an introduction to PythonNET
Calling Python from C#: an introduction to PythonNET ... In this way we can import any class, including C#'s System classes, and use...
Read more >How to call a Python function from C#
To call a Python function from C#, we'll use the Python.NET library. This package allows us to integrate Python with .NET projects and...
Read more >C# Windows Forms Application Tutorial with Example
Below is an example of a simple Windows form application C#. It shows a simple Login screen, which is accessible by the user....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Have you really looked at this?
https://github.com/pythonnet/pythonnet/wiki/Troubleshooting-on-Windows-and-Linux
On Wed, Feb 1, 2017, 8:39 AM tarpista notifications@github.com wrote:
Yes, I checked troubleshooting wiki, but could not succeed with it. Finally I found a workaround by using pythonnet in the other direction (as almost everyone does.), ie making .NET calls from python.
Basically now I make my gui in .NET (C#), and import it in python. In example my C# code looks like this:
As a post-build event in Visual Studio, I copy the compiled
NeuralNetsGUI.exefile into my python directory, so it is possible to import it in python: