我正在尝试使用 Process.Start() 启动可执行文件。当 exe 没有 DLL 依赖项时,它可以正常工作。但是,当我需要包含 2 个 DLL 时,它就不起作用了。我已尝试设置 WorkingDirectory,并已验证那里存在 2 个必需的 DLL。有任何想法吗?
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.CreateNoWindow = false;
startInfo.UseShellExecute = false;
startInfo.FileName = "memcached.exe";
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.Arguments = arguments; //not shown
startInfo.WorkingDirectory = Environment.CurrentDirectory;
try
{
using (Process exeProcess = Process.Start(startInfo))
{
exeProcess.WaitForExit();
}
}
catch (Exception ex)
{
Trace.TraceError(ex.Message); // never gets here
}
这是基于 Windows Azure Memcached 解决方案加速器的代码。当 memcached 无法启动时,会显示一个对话框。不幸的是,当代码在云中远程运行时,您看不到这一点。