2

I have a C# Application and I want to run python script by passing some arguments and i also want to return some values from python. should i make a .dll file of my python script ? or is there any other way.

I can't use ironpython because i am unable to import my python project libraries in ironpython

thanks

Arslan
  • 21
  • 1
  • Can't you just execute the command lines through the console via c#? Like so: http://stackoverflow.com/questions/1469764/run-command-prompt-commands – MiltoxBeyond Jul 03 '15 at 17:41

2 Answers2

1

Convert your Python script to executable using py2exe.exe, and call it from C# using Process.

Another way is to execute cmd command "python program.py" from your C# program. But, you've to make sure that environment variable for Python is set.

Muhammad Imran
  • 734
  • 7
  • 21
0

Use a Process. This will let you set the arguments. If possible, have the script write to STDOUT and capture that output with your Process object. There are plenty of tutorials on how to do this.

There's no good way to "return" a value from another process without capturing the output stream, especially considering that you're working with two different languages here.

Rogue
  • 636
  • 8
  • 22