This is an issue that has me pulling my hair out. TL:DR; IIS 7.5 webservice calls .exe which writes a file. Works when I navigate to the .asmx page (not in debug/cassini, actual IIS in chrome/FF) but doesn't work when I call the service from an applicaiton. Eventually this webservice call will need to come from a windows service call.
// --------------------------------------------------------------------
// Use the UTMs as the corners for the projwin in the gdal_translate call below
// --------------------------------------------------------------------
string sExecutionFile = string.Empty;
if ((ConfigurationSettings.AppSettings["BIN_PATH"]!=null) && File.Exists(ConfigurationSettings.AppSettings["BIN_PATH"] + "/gdal_translate.exe"))
sExecutionFile = Path.Combine(ConfigurationSettings.AppSettings["BIN_PATH"],"gdal_translate.exe");
else
sExecutionFile = "gdal_translate.exe";
ProcessStartInfo psi = new ProcessStartInfo(sExecutionFile,
"-projwin " + pointUL[0] + " " + pointUL[1] + " " +
pointLR[0] + " " + pointLR[1] + " " +
sImageFileName + " " + sResultsFileName);
psi.UseShellExecute = false;
psi.RedirectStandardOutput = true;
psi.RedirectStandardInput = true;
psi.RedirectStandardError = true;
psi.CreateNoWindow = true;
using(myProcess = new Process())
{
myProcess.StartInfo = psi;
myProcess.Start();
myProcess.WaitForExit();
myProcess.Close();
myProcess.Dispose();
}
The above code calls a small exe to generate a TIFF from another TIFF file. It's in a DLL wrapped up in a webservice call. I've got everything working and I can go to my localhost server, run the "DataService.asmx" page I created, fill out the form and biggity-bam, I have a TIFF in my new directory (also created by the webservice). I then wrote a small command-line applicaiton to attempt to call the webservice. It happily calls the webservice and a few others I tried for testing purposes. The problem is that I get the new directory created, but there's never any TIFF files inside of it. After debugging, my code is complaining that above code didn't create a file. What am I missing?
I've tried a variety of IIS 7.5 config options as well as OS-level permissions on the relevant directories. Going all the way up to "LocalSystem" yields the same behavior as going down to "AppPoolIdentity", "IUSR"... I have to believe that the above code is failing, even if it's not throwing any exceptions at all. Is there a better way to debug a ProcessStartInfo call from an IIS webservice? I could understand if this didn't work at all, or if I had to run it as an Admin account to get it to work, but the call works when I invoke it directly from the .asmx page.