I can not start the process (Process.Start ()) in BackgroundWorker (i.e. when it already executes the background process).

There are no exceptions, I tried to run other exe-files - nothing works. One of them simply had to create a left file to find out that the process was actually running, but this did not happen. Those. everything says that as though the exe-schnick did not start at all.

Code:

Process p1 = new Process(); p1.StartInfo.Arguments = args; p1.StartInfo.FileName = @"f:\exe.exe"; p1.Start(); p1.WaitForExit(); 

Has anyone encountered this problem?

  • no answer: (I can do that - ask questions) - megacoder
  • Options: 1. Put a bang or MessageBox.show around p1.Start (); and see whether there comes. 2. To refuse BackgroundWorker and to make a piece a standard flow. - SilverIce
  • I tried 1 - everything is fine, it comes, but it does not start 2 - I already started writing to your comment :) - megacoder
  • second option doesn't work either - megacoder
  • hm ... Claims to the special code no. Are any exceptions being generated? Well, maybe there are not enough rights, some file does not find it? Try to make sleep seconds for 10-15 in the started process to visually catch through the task manager. Try running this !! same code in the main thread. And check for any mistakes - the code is standard as a door - it’s hardly an error. - SilverIce

2 answers 2

The error, it turns out, was that the WorkingDirectory parameter was not specified, therefore the file indicating that the program was started was not created in the same place as the exe-file. Here's some annoying little thing on which you can "lohanutsya" :)

    I usually use the static method Process.Start(string fileName, string arguments)

    Never had a problem. Maybe non-static is not for this?