vb.netcrystal-reportscrystal-reports-2008

.NET 3.5 Migration to 4.5 issue with CrystalReports


I'm migrating an old .NET Framework 3.5 WinForm project to .NET Framework 4.5.2 and then it will be migrated to 4.8 but i have yet some problems with CrystalReports used in that project.

In:

   Dim rpt As New CrystalDecisions.CrystalReports.Engine.ReportDocument
        vedirpt = New CrystalDecisions.Windows.Forms.CrystalReportViewer
        rpt.PrintOptions.PrinterName = DammiPRNPDF()
        rpt.Load("C:\Project\RPT\VEN_ARTORA.rpt")
        rpt.SetDataSource(datsRPT)

I get an exception at like SetDataSource after the migration with the following stacktrace:

CrystalDecisions.CrystalReports.Engine.DataSourceException
  HResult=0x80041700
  Message=Unknown Query Engine Error
Error in File C:\Users\imytyuk\AppData\Local\Temp\VEN_RC {B1FC7324-0B9F-4E02-A31B-278FD0C30640}.rpt:
Unknown Query Engine Error
  Source=CrystalDecisions.ReportAppServer.DataSetConversion
  StackTrace:
   at CrystalDecisions.ReportAppServer.ConvertDotNetToErom.ThrowDotNetException(Exception e)
   at CrystalDecisions.CrystalReports.Engine.ReportDocument.SetDataSourceInternal(Object val, Type type)
   at CrystalDecisions.CrystalReports.Engine.ReportDocument.SetDataSource(DataSet dataSet)
   at Project.frmSTATVEL.VediVENRC(Int32 Dal, Int32 Al, String DaDATA, String ADATA, String Excel, String GRUPPO) in E:\VisualStudio\Visual Studio 2019\Project\Project\frmSTATVEL.vb:line 5501
   at Project.frmPRNREP.cmdPRNSCO_Click(Object sender, EventArgs e) in E:\VisualStudio\Visual Studio 2019\Project\Project\frmPRNREP.vb:line 90
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(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.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.RunDialog(Form form)
   at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
   at System.Windows.Forms.Form.ShowDialog()
   at Project.frmSTATVEL.cmdREPORT_Click(Object sender, EventArgs e) in E:\VisualStudio\Visual Studio 2019\Project\Project\frmSTATVEL.vb:line 13125
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(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.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.RunDialog(Form form)
   at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
   at System.Windows.Forms.Form.ShowDialog()
   at Project.frmCASSA.cmdRPT_Click(Object sender, EventArgs e) in E:\VisualStudio\Visual Studio 2019\Project\Project\frmCASSA.vb:line 41283
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(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.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
   at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
   at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
   at Project.My.MyApplication.Main(String[] Args) in :line 83

  This exception was originally thrown at this call stack:
    [External Code]

Inner Exception 1:
COMException: Unknown Query Engine Error
Error in File C:\Users\imytyuk\AppData\Local\Temp\VEN_RC {B1FC7324-0B9F-4E02-A31B-278FD0C30640}.rpt:
Unknown Query Engine Error

What can be done without changing the CR version? the projects uses CRRedis 2008


Solution

  • To make the older version of CrystalReport works on .NET Framework 4.5.2 and above i had to add the useLegacyV2RuntimeActivationPolicy set to true in app.config file.

    So the line from this:

    <startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" /></startup>
    

    Become this:

    <startup useLegacyV2RuntimeActivationPolicy="true"><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" /></startup>