c# - Why Process.Start doesn't work from asp.net web service? -


why code runs on development computer (win7 32bit) , on target server(2008r2 64bit) console app. when try run web service on target server nothing. no error, nothing.

if remove

exitmsg = proc.standardoutput.readtoend(); 

then fail error:

system.invalidoperationexception: process must exit before requested information can determined.

   [webmethod]     public string getrunningprocesses()     {         processstartinfo pinfo = new processstartinfo();         pinfo.filename = @"e:\bin\pslist.exe";                 pinfo.windowstyle = processwindowstyle.hidden;         pinfo.createnowindow = true;         pinfo.useshellexecute = false;         pinfo.redirectstandardoutput = true;          string exitmsg = "";         int exitcode = 1;          using (process proc = process.start(pinfo))         {             exitmsg = proc.standardoutput.readtoend();             proc.waitforexit(1000);             exitcode = proc.exitcode;         }          return exitmsg;     } 

i think there must user under code runs. web service code runs under asp.net user , might couses problems.

please advice me how fix this. thank much.

resolved


the problem eula dialog, poped invisble due processstartinfo settings. when run pslist.exe via cmd under account used application pool web service, prompted eula agreement , after everthing works fine.

the strange thing have "pinfo.arguments = "/accepteula";" in real code. should prevent probem, didn't , don't know why. if of knows why, please tell me.

thank help. trully peoples here.

i think problem with:

proc.waitforexit(1000); 

which instructs program wait second process finish. on machine, process finishes fine. on machine, though, may take longer. try changing to:

proc.waitforexit(); 

which wait indefinitely program exit.

you may want redirect output of process see if programming hanging or waiting else (or, in case, code).

in addition, process may hitting error , writing message standarderror rather standardoutput. try setting pinfo.redirectstandarderror = true; , reading see if there's you're missing.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -