2010-11-16 99 views
0

我的iis服務正在調用控制檯應用程序。該控制檯應用程序引用一個DLL。從IIS Web服務調用控制檯應用程序,不加載DLL的

當我檢查錯誤輸出我得到這個:

無法加載文件或程序集 '文件:/// C:\ WINDOWS \ SYSTEM32 \ INETSRV \ MYDLL.DLL'

什麼調用可執行正確的方法:

到目前爲止,我已經試過這樣:

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

回答

1

加入這一行:

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

補充一點:

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

如果你不這樣做,可執行文件將被從目錄中正在運行IIS啓動(C:\ WINDOWS \ SYSTEM32 \ INETSRV)。

相關問題