0

我的 iis 服务正在调用控制台应用程序。此控制台应用程序引用 DLL。

当我检查错误输出时,我得到了这个:

无法加载文件或程序集 'file:///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();
            }
4

2 回答 2

1

添加这一行:

p.StartInfo.WorkingDirectory = Path.GetDirectoryName(downloaderPath);
于 2010-11-16T13:12:28.413 回答
1

添加这个:

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

如果不这样做,可执行文件将从运行 IIS 的目录 (c:\windows\system32\inetsrv) 启动。

于 2010-11-16T13:13:08.553 回答