2010-11-16 105 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)。

相关问题