除非你看得不完全,否则不要投反对票。尽管有许多问题存在于同一个标题下,但这些问题都没有起作用,我想解决我的具体问题。请帮帮忙。
我正在处理C#4.0 Asp.Net应用程序,在网页上按一下按钮,我想要创建一个exe。所以我使用的是process.waitforexit devenv.exe,但是它挂在命令上。
这是工作,超过7个月,但两天前,它突然停止工作。它也在本地主机上工作,在服务器上发布之后,它就不能工作了。代码如下
System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo.FileName = "C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\Common7\\IDE\\devenv.exe";
process.StartInfo.Arguments = @"D:\ProjFolder\xxx.sln /rebuild";
process.StartInfo.UseShellExecute = false;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.ErrorDialog = false;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.RedirectStandardOutput = true;
OutputMsg = "";
if (!process.Start())
{
OutputMsg = "failed.</br>";
OutputMsg += process.StandardError.ReadToEnd();
HttpContext.Current.Response.Write(OutputMsg);
return false;
}
// Some people said that this is buffer problem, you should release it by reading
// output, i used "ReadToEnd" that is not working, so trying this again, and also it
// is not working
//while (!process.StandardOutput.EndOfStream)
//{
//string outputmsg = process.StandardOutput.ReadLine();
//HttpContext.Current.Response.Write(outputmsg);
//}
//string output = process.StandardOutput.ReadToEnd();
process.WaitForExit(60000);
if (process.HasExited)
{
OutputMsg = "Succeeded.";
HttpContext.Current.Response.Write(OutputMsg);
}
else
{
OutputMsg = "Process not completed properly.";
process.Kill();
HttpContext.Current.Response.Write(OutputMsg);
return false;
}发布于 2013-12-19 12:03:04
正如@Damien_The_Unbeliever所说,我尝试了MSBuild.Exe,它运行得很好。现在,人们还没有认识到为什么devenv.exe停止工作。
然而,msbuild.exe工作得很好。
注意: MSBuild.exe可以通过命令提示符使用,对于复杂的项目,我们可以使用这个命令行实用工具。
位于以下位置的msbuild.exe,请充分注意版本
C:\Windows\Microsoft.Net\Framework\v2.0.50727\MSBuild.exe
C:\Windows\Microsoft.Net\Framework\v3.5\MSBuild.exe
C:\Windows\Microsoft.Net\Framework\v4.0.30319\MSBuild.exe目标项目/解决方案框架版本和msbuild.exe版本应该相同。
如果有人需要关于msbuild.exe的帮助,这个链接可能过于使用完整的http://msdn.microsoft.com/en-us/library/ms164311%28v=vs.90%29.aspx,它包含整个命令行参数文档。
谢谢你的提示@Damien_The_Unbeliever。
发布于 2013-12-18 11:26:45
如果它在两天前工作,并且您没有将任何东西更改为您的代码,那么查看一下权限,可能是因为某些原因而更改了服务器上的权限。
其他方法,如果在( asp.net应用程序或.exe)的代码上发生了一些更改,从后退一步开始(取消最后的更改),然后再试一次,如果是的话,然后深入查看您的更改,问题就在那里。
对于进程的超时,它不应该超过http请求超时(默认设置为20秒)。
https://stackoverflow.com/questions/20656623
复制相似问题