【发布时间】:2009-07-23 13:04:22
【问题描述】:
我正在使用 Visual Studio 2005 的插件来调用外部进程。
当我在插件之外运行代码时 - 即在独立项目中它可以正常工作。但是,当我将其作为插件的一部分调用时,会进行 Process.Start() 调用但没有任何反应,后续代码行永远不会到达。
我尝试过使用标准权限和提升权限运行 VS,但效果相同。
代码如下 - 单击自定义菜单项时调用它:
string documentPath = @"C:\TestCode\TestApp\Testform.cs";
string folder = Path.GetDirectoryName(@"C:\TestCode\TestApp\");
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = "notepad.exe";
p.StartInfo.Arguments = documentPath;
p.StartInfo.UseShellExecute = true;
p.StartInfo.RedirectStandardOutput = true;
p.Start();
string output = p.StandardOutput.ReadToEnd();
我尝试了不同的可执行文件,但这没有任何区别。我在VS中以错误的方式解决这个问题吗?任何帮助表示赞赏。
【问题讨论】:
-
为什么你有'文件夹'当你甚至不使用它的时候?你试过调试吗?
-
在我清理了“真实”代码以便在此处发布后,我错误地将其留在了此处
-
仅供参考,当调试到它时,它到达了 process.start 然后什么也没做,它只是挂起......
标签: c# process visual-studio-addins