c# - Why does Process.Start(ProcessStartInfo) fail? -


we've developed new wpf application, , have had difficulty launching external c# script.

while calling process.start(processstartinfo) method processstartinfo object initialized both workingdirectory , filename successes, init filename property fails launch.

this not case when calling other application.
question - different approach start process has different logic?

see code more details:

 public void launchapp(){ /********************************/ /*      code passes        */ /********************************/ var pstartinfocalc1 = new processstartinfo     {         filename = @"c:\windows\system32\calc.exe",     };  process.start(pstartinfocalc1);  /*****************************/ /*  !!!this code fails  !!! */ /*****************************/ var pstartinfo1 = new processstartinfo     {         filename = @"c:\program files\myappfolder\myapp.exe",     };  process.start(pstartinfo1);  /********************************/ /*      code passes        */ /********************************/ var pstartinfo2 = new processstartinfo     {         workingdirectory = @"c:\program files\myappfolder",         filename = @"myapp.exe",     };  process.start(pstartinfo2);  /********************************/ /*      code passes        */ /********************************/ var pstartinfocalc2 = new processstartinfo     {         workingdirectory = @"c:\windows\system32\",         filename = @"calc.exe",     };  process.start(pstartinfocalc2); }` 

this image crashes: enter image description here

and following the problem signature crash screenshot:

 problem signature:   problem event name:   clr20r3   problem signature 01: myapp.exe   problem signature 02: 1.0.0.0   problem signature 03: 51ef9fd8   problem signature 04: mscorlib   problem signature 05: 4.0.30319.18052   problem signature 06: 5173bf28   problem signature 07: 266d   problem signature 08: a4   problem signature 09: system.windows.markup.xamlparse   os version:   6.1.7601.2.1.0.256.4   locale id:    1033   additional information 1: 1989   additional information 2: 1989c043e2e04efdbf18835c58bb867b   additional information 3: 37d3   additional information 4: 37d31c18f56cf3083b1c45ca83bbb78e  read our privacy statement online:   http://go.microsoft.com/fwlink/?linkid=104288&clcid=0x0409  if online privacy statement not available, please read our privacy statement offline:   c:\windows\system32\en-us\erofflps.txt 

when not specify working directory, new process inherit working directory of process. is, new process inherit working directory of process called process.start().

that's difference between 2 attempts start myapp. 1 of them inherits working directory, , 1 of them specifies it. myapp not run initial working directory being directory of parent process.

why so, cannot sure. seem myapp attempting xml parsing @ startup. perhaps xml parsing reads file presumed in working directory. in fact file located in same directory executable.

if case need modify myapp solve problem. instead of using relative path xml file, need build absolute path based on directory of executable file.

the myapp startup code can directory, this:

string exedir = system.io.path.getdirectoryname(system.reflection.assembly.     getexecutingassembly().location)); 

and use path.combine form full path xml file.


Comments

Popular posts from this blog

php - get table cell data from and place a copy in another table -

javascript - Mootools wait with Fx.Morph start -

php - Navigate throught databse rows -