C# 例外情况;请求的操作需要仰角“;当我运行.net代码时
我试图执行由我的.net核心web API用Python编写的“main.py”文件,但我遇到了一个异常 我已经授予Web API文件夹和Python代码文件夹的权限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
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,现在一切正常