Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/268.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 例外情况;请求的操作需要仰角“;当我运行.net代码时_C#_Python 3.x_.net Core - Fatal编程技术网

C# 例外情况;请求的操作需要仰角“;当我运行.net代码时

C# 例外情况;请求的操作需要仰角“;当我运行.net代码时,c#,python-3.x,.net-core,C#,Python 3.x,.net Core,我试图执行由我的.net核心web API用Python编写的“main.py”文件,但我遇到了一个异常 我已经授予Web API文件夹和Python代码文件夹的权限 var file = Configuration.GetValue<string>("DE.PythonPath"); ProcessStartInfo start = new ProcessStartInfo(); start.FileName = file; st

我试图执行由我的.net核心web API用Python编写的“main.py”文件,但我遇到了一个异常

我已经授予Web API文件夹和Python代码文件夹的权限

 var file = Configuration.GetValue<string>("DE.PythonPath");
        ProcessStartInfo start = new ProcessStartInfo();
        start.FileName = file; 
        start.Arguments = string.Format("{0} {1}", cmd, args);
        start.UseShellExecute = false;
        start.RedirectStandardOutput = true;
        using (Process process = Process.Start(start))
        {
            string stderr = process.StandardError.ReadToEnd();
            using (StreamReader reader = process.StandardOutput)
            {                   
                string result = reader.ReadToEnd();
                return result;
            }
        }
var file=Configuration.GetValue(“DE.PythonPath”);
ProcessStartInfo start=新的ProcessStartInfo();
start.FileName=文件;
start.Arguments=string.Format(“{0}{1}”,cmd,args);
start.UseShellExecute=false;
start.RedirectStandardOutput=true;
使用(Process进程=Process.Start(Start))
{
字符串stderr=process.StandardError.ReadToEnd();
使用(StreamReader=process.StandardOutput)
{                   
字符串结果=reader.ReadToEnd();
返回结果;
}
}

我希望python代码能够运行,但它给出了异常“请求的操作需要提升”

Visual studio需要以管理员身份运行。因此,使用(Process Process=Process.Start(Start))以管理员身份运行Visual studio这一行给出了错误尝试以AdminThank@viveknuna的身份打开VisualStudio,现在一切正常