【发布时间】:2014-09-12 10:08:54
【问题描述】:
似乎在 Windows 7 64 位 (SP1) 机器上尝试使用 System.Drawing.Printing.PrintDocument 命名空间时效果很好。但是在 Server 2008 R2 64 位 (SP1) 机器上尝试相同的代码,它只是挂在代码中。不抛出异常等...
这是我的代码的 sn-p...
private bool PrintTIF(string sPrinter, string sFile)
{
try
{
//Open file for printing
WriteEvent(105, "Opening the file for printing using streamreader...", CustomLogTool.EventLogEntryTypeExtentions.Debug);
m_PrinterFile = new StreamReader(sFile);
//Set the document name
WriteEvent(105, "Set the document name.", CustomLogTool.EventLogEntryTypeExtentions.Debug);
m_Printer.DocumentName = Path.GetFileName(sFile);
//Print file
WriteEvent(105, "Sending the file to the printer...", CustomLogTool.EventLogEntryTypeExtentions.Debug);
m_Printer.Print();
m_PrinterFilesPrinting.Add(new PrintInfo(sFile, null, sPrinter));
//Close file
WriteEvent(105, "Closing the file and destorying the streamreader object.", CustomLogTool.EventLogEntryTypeExtentions.Debug);
m_PrinterFile.Close();
//Success
return true;
}
catch (Exception ex)
{
try { m_PrinterFile.Close(); }
catch { }
WriteEvent(201, ex.Message, CustomLogTool.EventLogEntryTypeExtentions.Debug);
return false;
}
}
我收到的日志事件最多为“将文件发送到打印机...”。我什么也没得到,我希望在异常中收到我的错误 201 消息。但我什么也得不到。就好像程序挂了一样。我猜这是由于从 Win7 (SP1) 更改为 Server2008R2(SP1) 造成的。有什么想法吗?
【问题讨论】:
-
从不、从、从尝试从服务打印。您看不到打印机驱动程序警报。
-
我的应用程序的重点是从服务打印...为什么我不能将那些“打印机驱动程序警报”包装到事件日志条目中?您能否详细说明“打印机驱动程序警报”?它们是什么,我怎样才能看到它们或访问它们等等......任何东西......