title: Using phyton.exe in .net c# controller:
body: <p>could not load file or assembly 'python.runtime' or one of its dependencies ,an attempt was made to load a program with an in correct format</p>
  
  <p>im am facing same problem, My error was not resolved using phyton 3.5 , calling the phyton.exe path to execute phyton file in .net c# controller ,facing error only after publishing in to the server ,it working fine in my system</p>
  
  <p>below was my code</p>
  
  <pre><code>if (Result.Success)
  {
      System.Diagnostics.Process process = new System.Diagnostics.Process();
      System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
      startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
      startInfo.FileName = "C:/Program Files/Python 3.5/python.exe";
      startInfo.Arguments = "C:/PythonScripts/Test.py";
      // startInfo.Arguments = HttpContext.Server.MapPath("~/PythonScripts/Test.py").ToString();
  
      startInfo.Verb = "runas";
      startInfo.UseShellExecute = false;
      startInfo.RedirectStandardError = true;
      startInfo.RedirectStandardOutput = true;
      process.StartInfo = startInfo;
      bool t = process.Start();
  
      StreamReader myStreamReader = process.StandardError;
      string error = myStreamReader.ReadToEnd();
  
      StreamReader reader = process.StandardOutput;
      string output = reader.ReadToEnd();
  
      process.WaitForExit();
      process.Close();
  
      if (!error.Equals(""))
      {
          Result.Success = false;
          Result.Exception = true;
      }
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/rkM6T.png" rel="nofollow noreferrer">enter image description here</a></p>