1705095 - Error: Class not registered - CrystalPrintControl when using the InProc RAS SDK PrintOutputController

SAP Knowledge Base Article - Public

1705095 - Error: Class not registered - CrystalPrintControl when using the InProc RAS SDK PrintOutputController

Symptom

  • Using the PrintOutputController to print a report works if the application is compiled as 32 bit
  • The application compiled as 64 bit results in the following error:

System.Runtime.InteropServices.COMException (0x80040154): Class not
registered - CrystalPrintControl at
CrystalDecisions.ReportAppServer.Controllers.PrintOutputControllerClass.PrintReport(PrintReportOptions options)
  at Unmanaged_RAS10_CSharp_Printers.frmMain.btnPrintToPrinter_Click
(Object sender, EventArgs e)
  at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
  at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
button, Int32 clicks)
  at System.Windows.Forms.Control.WndProc(Message& m)
  at System.Windows.Forms.ButtonBase.WndProc(Message& m)
  at System.Windows.Forms.Button.WndProc(Message& m)
  at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32
msg, IntPtr wparam, IntPtr lparam)

Environment

  • Crystal Reports for Visual Studio 2010
  • Visual Studio 2010

Reproducing the Issue

  • Create a new win app in VS 2010 using Crystal Reports for Visual Studio 2010
  • Use the following code to print a report to a printer:
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.ReportAppServer.Controllers;
using CrystalDecisions.ReportAppServer.ClientDoc;
using CrystalDecisions.ReportAppServer.ReportDefModel;
CrystalDecisions.CrystalReports.Engine.ReportDocument rd =
new CrystalDecisions.CrystalReports.Engine.ReportDocument();
//ReportDocument rd = new ReportDocument();
 ISCDReportClientDocument rcd;
  PrintOutputController poc;
  PrintReportOptions po = new PrintReportOptions();
 rd.Load(@"C:\CrystalReport1.rpt");
  rcd = rd.ReportClientDocument;
  poc = rcd.PrintOutputController;
  po.PrinterName = "Microsoft XPS Document Writer";
  po.PrinterDuplex =
CrPrinterDuplexEnum.crPrinterDuplexSimplex;
  po.NumberOfCopies = 1;
  poc.PrintReport(po);
  rd.Close();
  rd.Dispose();

 

Cause

  • This is a limitation of the 64 bit builds and SDK for visual Studio .NET
  • The PrintOutputController has a dependency on the PrintControll dll
  • It is not possible to make this control 64 bit compatible due to limitations in IE 64, framework dependencies and other

Resolution

  • Work-around; use the PrintToPrinter API

Keywords

CR2010 2010 CR4VS2010 CR4VS VS2010 NET2010 Crystal Reports for .NET Framework 4.0 crforvs 13 printer activex active report application server In_Process , KBA , BI-DEV-NET-SDK , .NET SDK / COM SDK , Problem

Product

SAP Crystal Reports, developer version for Microsoft Visual Studio