2015-06-22 43 views
0

我一直在遇到這個問題一個月了,我試了一切來解決它,但沒有反應...(儘量減少數據的負載..),反正此錯誤顯示桌面未重新啓動3天,但如果重新啓動桌面,則不會顯示該錯誤。請人以極大的心靈幫我感謝水晶報告拋出OutOfMemoryException/Win32Exception(該句柄無效)

private void Print(string querySTR, string printerName, bool isShort) 
    { 
     ReportDocument cryRpt = new ReportDocument(); 
     DataSet Ds = null; 
     OracleDataAdapter adapter = null; 
     try 
     { 
      PrintModule prntM = new PrintModule(); 
      OracleConnection conn = new OracleConnection(prntM.conn); 
      adapter = new OracleDataAdapter(querySTR, conn); 

      Ds = new DataSet(); 
      adapter.Fill(Ds, "Data"); 

      if (Ds.Tables[0].Rows.Count == 0) 
      { 
       throw new Exception("No Batch found to print."); 
      } 


      if (isShort) 
      { 
       cryRpt.Load("Template4SHORT.rpt"); 
      } 
      else 
      { 
       cryRpt.Load("Template4LONG.rpt"); 
      } 

      cryRpt.SetDataSource(Ds); 


      cryRpt.PrintOptions.DissociatePageSizeAndPrinterPaperSize = true; 
      cryRpt.PrintOptions.PrinterName = printerName; 

      cryRpt.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Landscape; 
      cryRpt.PrintToPrinter(1, false, 1, 1); 


     } 
     catch (Exception ex) 
     { 
      MessageBox.Show("ERROR IN PRINT FUNCTION " + ex.ToString()); 
      Logger.Error("ERROR IN PRINT FUNCTION " + ex.Message, "PRINTMCONTROLLER"); 
     } 
     finally 
     { 
      Ds.Dispose(); 
      cryRpt.Dispose(); 
      GC.SuppressFinalize(this); 
     } 
    } 

enter image description here

+0

你是否在另一個桌面上試過這個,看看錯誤是否存在。 – vcs

+0

是的,我在2臺桌面上部署了它們,它們都出現此錯誤。 – porknbeans

+0

@vcs嗯..有沒有一種方法來衡量或識別我製作的應用程序是否能夠在體面的內置桌面上運行?我是軟件開發新手。 – porknbeans

回答

0

其打印機的問題不是水晶報表,嘗試安裝正確的驅動程序,還可以設置默認打印機,調試代碼,並檢查是否它在您調用Print(...)方法時選擇正確的名稱。

+0

看看這些 http://i.imgur.com/Eu5alhd.jpg 我認爲它在printername中, ,我也將打印機設置爲默認值。 – porknbeans

+0

告訴我,如果您有其他解決方案,請儘快修復此問題.. – porknbeans

+0

DareDevil會在我的開發中發生衝突,如果在我的開發中Crystal報告的頁面設置的打印機名稱是「Oce VarioStream 6100 PCL V4.00」部署dekstop打印機名稱的名稱是「Oce VarioStream 6100 PCL V4.00 Printer1」? – porknbeans