1
votes

We have a windows application that is built on .NET remoting. It’s a 32 bit application built using .NET Framework 2.0. We are using SAP Crystal reports run time engine for .NET Framework 4 (32-bit – Version 13.0.3) for reports functionality. There is a printing functionality also which prints the respective report to the chosen printer by the user during the batch run . This entire setup works fine on a Windows server 2003 server. Now we are trying to migrate the application to Windows server 2008 , the printing is not working correctly. It is always printing the reports to the default printer on the Windows server 2008 machine instead of printing it to the chosen printer.

CrystalDecisions.CrystalReports.Engine, CrystalDecisions.ReportSource & CrystalDecisions.Shared are the DLL’s that are referenced from

C:\Program Files\sap businessobjects\crystal reports for .net framework 4.0\common\sap businessobjects enterprise xi 4.0\win32_x86

We converted the application to 64 bit version. On the Windows server 2008 even though we installed , SAP Crystal reports run time engine for .NET Framework 4 (64-bit – Version 13.0.3), the printing is not working correctly (Printing always to the default printer). Also couldn’t find the above DLL’s in the 64 bit installation folder.

C:\Program Files\sap businessobjects\crystal reports for .net framework 4.0\common\sap businessobjects enterprise xi 4.0\win64_x64

I couldn’t find any issue with code, I think it’s definitely a compatibility problem. I am stuck with this issue for more than a month. Please help.

1
The Printer installation command getting executed in the code has been modified through change in the configuration file, as the paths for the printer related files (provided by Microsoft) are different in Windows server 2003 and 2008. Windows server 2003: c:\windows\system32\cscript.exe C:\Windows\ system32\prnmngr.vbs -ac -p printer name Windows server 2008: c:\windows\system32\cscript.exe C:\Windows\SysWOW64\Printing_Admin_Scripts\en-US\prnmngr.vbs -ac -p printer namehakuna

1 Answers

4
votes

We found the issue and the fix. Its related to code.

string printPath = System.Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
string rptFileName=@"\sample.rpt";
string PrinterName=Console.ReadLine();

ReportDocument reportDocument = new ReportDocument();
reportDocument.Load(printPath + rptFileName);
reportDocument.PrintOptions.PrinterName = PrinterName;           
reportDocument.PrintToPrinter(1, true, 0, 0);

reportDocument.PrintOptions.PrinterName is always empty even the right printer name is assigned. The code has been changed as follows and the same worked on Windows server 2008 R2 with existing set installations (SAP Crystal reports 32 bit/64 bit version - 13.0.3) without even converting to 64 bit.

ReportDocument reportDocument = new ReportDocument();
reportDocument.Load(printPath + rptFileName);
System.Drawing.Printing.PrinterSettings printerSettings = new System.Drawing.Printing.PrinterSettings();
printerSettings.PrinterName = PrinterName;
reportDocument.PrintToPrinter(printerSettings, new PageSettings(), false);