Select to view content in your preferred language

Issues with call Arcpy script in C#

05-04-2018 02:17 AM
New Contributor

Hey All,

I have a python script that I would like to call from form events in WPF project. The C# code snippet to call Arcpy script like below.

var startInfo = new ProcessStartInfo() {
     CreateNoWindow = false,
     UseShellExecute = false,
     FileName = pathToArcGISPythonRuntime,
     WindowStyle = ProcessWindowStyle.Hidden,
     Arguments = pathToMyArcpyScript+""+allTheParams
var exeProcess= Process.Start(startInfo);

The script is used for create a Network Dataset and publish it as a NAService.The script runs well in ArcGIS Desktop and in Cmd console every time.But I'm facing two issues when call it in C# like the method above.

1.The Arcpy script will failed at import arcpy in some computers when runing the WPF project while other computers work well . All the Computers installed  the same ArcGIS Desktop 10.6 and ArcGIS Server10.6 with the right licence.

2.In some computers when the Arcpy script call the arcpy.CreateNetworkDatasetFromTemplate_na() method, there will be a python.exe has stopped working error popup like the picture below.If i run the Arcpy script in Cmd console in those computers there is no error.

The full python script is attached,Any suggestions or ideas about issues would be very appreciated!



0 Kudos
0 Replies