.NET 3.5 迁移到 4.5 问题与 CrystalReports
.NET 3.5 Migration to 4.5 issue with CrystalReports
我正在将旧的 .NET Framework 3.5 WinForm 项目迁移到 .NET Framework 4.5.2,然后它将迁移到 4.8,但我在该项目中使用的 CrystalReports 还存在一些问题。
在:
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)
迁移后,我在类似 SetDataSource 处遇到异常,堆栈跟踪如下:
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
不更改CR版本可以做什么?项目使用 CRRedis 2008
为了使旧版本的 CrystalReport 在 .NET Framework 4.5.2 及更高版本上运行,我必须在 app.config
文件中添加 useLegacyV2RuntimeActivationPolicy
设置为 true
。
所以这行:
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" /></startup>
变成这样:
<startup useLegacyV2RuntimeActivationPolicy="true"><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" /></startup>
我正在将旧的 .NET Framework 3.5 WinForm 项目迁移到 .NET Framework 4.5.2,然后它将迁移到 4.8,但我在该项目中使用的 CrystalReports 还存在一些问题。
在:
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)
迁移后,我在类似 SetDataSource 处遇到异常,堆栈跟踪如下:
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
不更改CR版本可以做什么?项目使用 CRRedis 2008
为了使旧版本的 CrystalReport 在 .NET Framework 4.5.2 及更高版本上运行,我必须在 app.config
文件中添加 useLegacyV2RuntimeActivationPolicy
设置为 true
。
所以这行:
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" /></startup>
变成这样:
<startup useLegacyV2RuntimeActivationPolicy="true"><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" /></startup>