0

My iis service is calling a console app. This console app references a DLL.

When I check the error output I get this :

Could not load file or assembly 'file:///c:\windows\system32\inetsrv\MyDll.dll'

What is the correct way to call the executable:

So far I've tried this:

 using (var p = new System.Diagnostics.Process())
            {
                p.StartInfo.UseShellExecute = false;
                p.StartInfo.RedirectStandardOutput = true;
                p.StartInfo.RedirectStandardError = true;
                p.StartInfo.RedirectStandardInput = true; 
                p.StartInfo.FileName = downloaderPath;
                p.Start();
                string o = p.StandardOutput.ReadToEnd();
                string i = p.StandardError.ReadToEnd(); 
                p.WaitForExit();
            }
JL.
  • 78,954
  • 126
  • 311
  • 459

2 Answers2

1

Add this line:

p.StartInfo.WorkingDirectory = Path.GetDirectoryName(downloaderPath);
Aliostad
  • 80,612
  • 21
  • 160
  • 208
1

Add this:

p.StartInfo.WorkingDirectory = "c:\mydir\";

If you don't, the executable will be started from the directory where IIS is running (c:\windows\system32\inetsrv).

Gerrie Schenck
  • 22,148
  • 20
  • 68
  • 95