我的问题是:我使用ghostscript将一些pdf转换为jpeg文件,然后将它们渲染成silverlight控件。我转换使用PDF文件:Ghostscript崩溃服务器
public void PdfToJpg(string ghostScriptPath, string input, string output) {
timer1.Enabled = true;
//if the pdf has more than 1 file (ex. 3) then 3 jpeg files will be outputed
String ars = "-dNOPAUSE -sDEVICE=jpeg -r300 -o" + output + "-%d.jpeg " + input;
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.Arguments = ars;
startInfo.FileName = ghostScriptPath;
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
using (Process exeProcess = Process.Start(startInfo)) {
exeProcess.WaitForExit();
}
}
然后保存会话中的页码和到字典中的页面的byte [],字典和一个Silverlight的支持服务发送它,并把它们发送到ASPX页面包含Silverlight控件(使用Response.redirect(page.aspx))。一切正常,但有时服务器(卡西尼或IIS)崩溃,这意味着文件被转换,但重定向从不发生,只是页面保持加载状态。我必须用“结束进程”关闭cassini或重新启动IIS服务器,以使进程再次运行。我不认为问题是与服务,因为我有一个类似的过程发送到silverlight应用一个字节[]的音频文件,一切正常,服务器永远不会卡住,所以我认为这是因为ghostscript ..如果有人有任何想法。另外我使用elmah,并没有错误报告...当在调试时,当我点击视图按钮,其中包含转换和其他部分的过程它不会进入点击事件,但转换完成(不是重定向),我不知道这怎么可能......谢谢。所以可以肯定的是一些与ghostscript的
UPDATE: 我改变了我的代码:
using (Process convertProc = new Process()) {
convertProc.StartInfo.FileName = ghostScriptPath;
convertProc.StartInfo.Arguments = args;
//convertProc.StartInfo.UseShellExecute = false;
//convertProc.StartInfo.RedirectStandardOutput = true;
convertProc.StartInfo.CreateNoWindow = true;
convertProc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
convertProc.Start();
ThreadedKill(convertProc.Id);
convertProc.PriorityClass = ProcessPriorityClass.Normal;
convertProc.WaitForExit();
}
如果useshellexecute和redirectoutput被注释掉服务器变为“野生”有时,如果没有,代码运行完美每次,但是这个从ghostscript进程出现的窗口,我不想那样。为了不出现,我必须评论这行或将useshellexecute设置为true,并评论redirectoutput,这有时会导致失败。我能做什么?什么是redirectStandardOutput和它是什么... ...不知道在MSDN ...
更新2: 更改我的gswin64.exe gswin64c.exe为控制台应用程序,现在我说的窗口isn再也没有出现。无码疯了......,至少目前还没有..
要解决这个问题,您可能需要提供有关错误的更多特定信息,例如一个堆栈跟踪或至少一个Windows错误代码的异常。事件日志中记录了什么? –
这是问题,没有例外,事件查看器中没有错误,没有任何错误,在TaskManager中,gswin64.exe在挂起时不运行。 – adi1989
GPL Ghostscript 9.06(2012-08-08)gswin64.exe – adi1989