Search code examples
web-servicesiisshellexecute

Calling console app from IIS web service, not loading DLL's


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();
            }

Solution

  • Add this line:

    p.StartInfo.WorkingDirectory = Path.GetDirectoryName(downloaderPath);