简体   繁体   English

ASP.NET Process.Start在IIS8上不起作用(Windows 8.1)

[英]ASP.NET Process.Start not working on IIS8 (Windows 8.1)

I've been trying to get this working for the past couple of days and tried every solution suggested including the one here: 在过去的几天里,我一直在努力使这一工作正常进行,并尝试了所有建议的解决方案,包括此处的解决方案:

System.Diagnostics.Process.Start not work from an IIS System.Diagnostics.Process.Start无法从IIS工作

This code (ASP.NET MVC Web Application) works perfectly on IIS7 (Windows 7). 此代码(ASP.NET MVC Web应用程序)在IIS7(Windows 7)上完美运行。

The code just print a PDF file using Adobe Reader in a local printer (intranet) from the server: 该代码只需使用Adobe Reader从服务器在本地打印机(内联网)中打印PDF文件:

// print receipt
ProcessStartInfo psInfo = new ProcessStartInfo();
psInfo.FileName = acrobatReaderPath;
psInfo.WorkingDirectory = System.IO.Path.GetDirectoryName(psInfo.FileName);
psInfo.Arguments = String.Format("/s /o /h /t \"{0}\" \"{1}\"", filePath, printerName);
psInfo.WindowStyle = ProcessWindowStyle.Hidden;
psInfo.CreateNoWindow = true;
psInfo.UseShellExecute = true;
Process process = Process.Start(psInfo);

The Application Pool Identity is a local privileged account. 应用程序池标识是本地特权帐户。 Like I said before, it works on IIS7. 就像我之前说的,它可以在IIS7上运行。

The strange thing is that I can see the background process started (AcroRd32.exe) in the Task Manager including the Command Line used to launch it. 奇怪的是,我可以在任务管理器中看到启动了后台进程(AcroRd32.exe),包括用于启动它的命令行。 If I copy the Command Line and run it the PDF prints without problem. 如果我复制命令行并运行它,PDF可以正常打印。

Is there something I'm missing? 有什么我想念的吗?

I know there are better ways to do this. 我知道有更好的方法可以做到这一点。 Suggestions are also welcome. 也欢迎提出建议。

UPDATE: 更新:

Clarification: The issue is that the process is not finishing and the PDF is not printing. 澄清:问题是该过程尚未完成,PDF无法打印。

Apparently the issue is more of a bitness (32 vs 64). 显然问题出在一点点(32 vs 64)。 I'm still debugging. 我还在调试。

The code IS PRINTING the PDFs in the following scenarios: 代码在以下情况下正在打印 PDF:

  • Visual Studio 2012 IIS Express on Windows 7 (64 bits) Windows 7(64位)上的Visual Studio 2012 IIS Express
  • IIS7 on Windows Server 2008 Standard (32 bits) Windows Server 2008 Standard(32位)上的IIS7

The code IS NOT PRINTING the PDFs in the following scenarios: 在以下情况下,代码不会打印 PDF:

  • Visual Studio 2012 IIS7 on Windows 7 (64 bits) Windows 7(64位)上的Visual Studio 2012 IIS7
  • IIS8 on Windows 8.1 (64 bits) Windows 8.1上的IIS8(64位)

The application pool is running with an Administrator account and the Enable 32-Bit Applications is set to True in Advance Settings. 应用程序池正在使用管理员帐户运行,并且在“高级设置”中将“启用32位应用程序”设置为True。

The World Wide Web Publishing Service (W3SVC) has the Allow service to interact with desktop checked in the Properties. 万维网发布服务(W3SVC)在“属性”中选中了“允许服务与桌面交互”。

Please let me know if anyone knows how to solve this. 如果有人知道如何解决此问题,请告诉我。 Thanks. 谢谢。

Changed Acrobat Reader for Foxit Reader ( https://www.foxitsoftware.com/products/pdf-reader/ ) and it solved the problem. 将Acrobat Reader更改为Foxit Reader( https://www.foxitsoftware.com/products/pdf-reader/ ),从而解决了该问题。 The command line is very similar. 命令行非常相似。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM