看起來,當試圖在Windows 7 64位(SP1)盒子上使用System.Drawing.Printing.PrintDocument命名空間時,它很好用。但是,在Server 2008 R2 64位(SP1)框上嘗試相同的代碼,並且它只是掛在代碼中。沒有異常拋出,等...Windows Server 2008 R2 Standard的PrintDocument問題64位
這裏是我的代碼片段...
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)的原因。有任何想法嗎?
從不,*從不*,**從不**嘗試從服務打印。您看不到打印機驅動程序警報。 –
我的應用程序的重點是從服務打印...爲什麼我不能將這些「打印機驅動程序警報」包裝到事件日誌條目中?你能否詳細說明「打印機驅動程序警報」?他們是什麼,我怎麼能看到他們或獲得他們的訪問等...任何... –