问题描述:在WCF服务里面通过调用python.exe来执行py文件,像下面这样py文件路径+参数,用空格隔开。会出现调用结果为空的现象
System.Diagnostics.ProcessStartInfo procStartInfo = new System.Diagnostics.ProcessStartInfo(pyPath, filepath + Params);
procStartInfo.RedirectStandardOutput = true;
procStartInfo.UseShellExecute = false;
procStartInfo.CreateNoWindow = true;
using (System.Diagnostics.Process process = System.Diagnostics.Process.Start(procStartInfo))
{
using (StreamReader reader = process.StandardOutput)
{
string result = reader.ReadToEnd();
return result;
}
}
设置pyton文件路径的可访问性(权限问题),右键——属性——安全——添加用户
在python里面引用arcpy。但在pyton64位exe可以,在python32位exe结果为空,用pythonshell去运行结果是对的。目前知道64位调用arcpy是ArcGISserver中的,32位是Destop中的。