报告查看器在MDI winform中崩溃(仅在生产中) [英] reportviewer crash in MDI winform (only in production)

查看:59
本文介绍了报告查看器在MDI winform中崩溃(仅在生产中)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用VS 2005(RTM 050727.4200)来编写winforms应用程序,

I'm using VS 2005 (RTM 050727.4200) , to coding a winforms app,

我有表格(JobList.vb)用几个datagridview来显示很多项,当用户单击一个按钮(btnReportColor)时,它打开一个带有参数(JobID)的新表单,新表单只包含一个reportviewer控件,并填充一个数据集使用要在报告中显示的数据。

i have form (JobList.vb) with a couple of datagridview to show many items, when the user click a button (btnReportColor ) , its open a new form with a parameter (JobID), the new form  only contain a reportviewer control, and fill a dataset with the data to show in the report.

问题是,当调用报告表单两次(调用一个,查看报告,关闭报告窗口,然后再次调用)时,报表呈现时(窗口显示,绿色圆形进度条开始显示)应用程序崩溃,并且在创建窗口句柄之前,无法在控件上调用Invoke或BeginInvoke。"

The problem is that when invoke the report form two times(invoke one,view the report,close the report window, and invoke again), the application crash when the report is rendering (the window show, and the green circular progress bar begin to show) with the error "Invoke or BeginInvoke cannot be called on a control until the window handle has been created."

此错误仅在发布模式下显示,从exe执行时,如果我在VS2005 IDE中执行了相同的步骤,没有错误,并且报告始终显示正确。

this error only show in release mode, when executing from the exe, if I made the same steps in the VS2005 IDE, no errors and the reports shows correctly all the time.

提前致谢。

PD:我为f道歉或者是不好的编辑,因为英语不是我的第一语言。

PD: I apologize for the poor redaction, because english is not my first language.

(JobList.vb)

(JobList.vb)

私人 Sub btnReportColor_Click( B yVal sender As System.Object, ByVal e As System.EventArgs) 句柄 btnReportColor.Click

Private Sub btnReportColor_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReportColor.Click

Dim SelectedRowView As Data.DataRowView

Dim SelectedRowView As Data.DataRowView

Dim SelectedRow As exwDataSet.jobsRow

Dim SelectedRow As exwDataSet.jobsRow

如果 IsNothing(JobsBindingSource.Current) 然后

If Not IsNothing(JobsBindingSource.Current) Then

SelectedRowView = CType (JobsBindingSource.Current,System.Data.DataRowView)

SelectedRowView = CType(JobsBindingSource.Current, System.Data.DataRowView)

SelectedRow = CType (SelectedRowView.Row,exwDataSet.jobsRow)

SelectedRow = CType(SelectedRowView.Row, exwDataSet.jobsRow)

Dim xForm As ReportColor

Dim xForm As ReportColor

xForm = ReportColor

xForm = New ReportColor

尝试

Try

xForm.cargarReport(SelectedRow.jobID )

xForm.cargarReport(SelectedRow.jobID)

xForm.ShowDialog( Me

xForm.ShowDialog(Me)

最后

Finally

xForm.Dispose()

xForm.Dispose()

End 尝试

End Try

End If

End If

结束 Sub

< font color ="#0000ff"size = 2>(reportColor.vb)

Public Class ReportColor

Public Class ReportColor

Sub cargarReport( ByVal jobID As 整数

Sub cargarReport(ByVal jobID As Integer)

Me .ViewReportColorTableAdapter.FillByJobID( Me .exwDataSet.ViewReportColor,jobID)

Me.ViewReportColorTableAdapter.FillByJobID(Me.exwDataSet.ViewReportColor, jobID)

Me 。 ReportViewer1.RefreshReport()

Me.ReportViewer1.RefreshReport()

结束 Sub

End Sub

结束 Class

End Class

 

< 全局 .Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _

<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _

部分 Class ReportColor

Partial Class ReportColor

Inherits < font size = 2> System.Windows.Forms.Form

Inherits System.Windows.Forms.Form

'表格覆盖dispose以清理组件列表。

'Form overrides dispose to clean up the component list.

< System.Diagnostics.DebuggerNonUserCode()> _

<System.Diagnostics.DebuggerNonUserCode()> _

受保护 覆盖 Sub Dispose( < font color ="#0000ff"size = 2> ByVal disposing As 布尔

Protected Overrides Sub Dispose(ByVal disposing As Boolean)

If disposing AndAlso components < font color ="#0000ff"size = 2> IsNot Nothing 然后

If disposing AndAlso components IsNot Nothing Then

components.Dispose()

components.Dispose()

结束 If

End If

MyBase .Dispose(处置)

MyBase.Dispose(disposing)

结束 Sub

End Sub

'Windows窗体要求设计师

'Required by the Windows Form Designer

私人 组件 As System.ComponentModel.IContainer

Private components As System.ComponentModel.IContainer

'注意:Windows窗体设计器需要以下步骤

'NOTE: The following procedure is required by the Windows Form Designer

'可以使用Windows窗体设计器修改它。

'It can be modified using the Windows Form Designer.

'不要使用代码编辑器修改它。

'Do not modify it using the code editor.

< System.Diagnostics.DebuggerStepThrough()> _

<System.Diagnostics.DebuggerStepThrough()> _

私人 Sub InitializeComponent()

Private Sub InitializeComponent()

Me .components = System.ComponentModel.Container

Me.components = New System.ComponentModel.Container

Dim ReportDataSource1 As Microsoft.Reporting.WinForms.ReportDataSource = New Microsoft.Reporting.WinForms.ReportDataSource

Dim ReportDataSource1 As Microsoft.Reporting.WinForms.ReportDataSource = New Microsoft.Reporting.WinForms.ReportDataSource

Me .ReportViewer1 = New Microsoft.Reporting.WinForms.ReportViewer

Me.ReportViewer1 = New Microsoft.Reporting.WinForms.ReportViewer

Me .exwDataSet = exw.exwDataSet

Me.exwDataSet = New exw.exwDataSet

Me .ViewReportColorBindingSource = New System.Windows.Forms.BindingSource( Me .components)

Me.ViewReportColorBindingSource = New System.Windows.Forms.BindingSource(Me.components)

Me .ViewReportColorTableAdapter = exw.exwDataSetTableAdapters.ViewReportColorTableAdapter

Me.ViewReportColorTableAdapter = New exw.exwDataSetTableAdapters.ViewReportColorTableAdapter

CType < font size = 2>( Me .exwDataSet,System.ComponentModel.ISupportInitialize).BeginInit()

CType(Me.exwDataSet, System.ComponentModel.ISupportInitialize).BeginInit()

CType .ViewReportColorBindingSource,System.ComponentModel.ISupportInitialize).BeginInit()

CType(Me.ViewReportColorBindingSource, System.ComponentModel.ISupportInitialize).BeginInit()

Me .SuspendLayout()

Me.SuspendLayout()

'

'

'ReportViewer1

'ReportViewer1

'

'

Me .ReportViewer1.Dock = System.Windows.Forms.DockStyle.Fill

Me.ReportViewer1.Dock = System.Windows.Forms.DockStyle.Fill

ReportDataSource1.Name = " exwDataSet_ViewReportColor"

ReportDataSource1.Name = "exwDataSet_ViewReportColor"

ReportDataSource1.Value = Me .ViewReportColorBindingSource

ReportDataSource1.Value = Me.ViewReportColorBindingSource

Me .ReportViewer1.LocalReport.DataSources.Add(ReportDataSource1)

Me.ReportViewer1.LocalReport.DataSources.Add(ReportDataSource1)

Me .ReportViewer1.LocalReport.ReportEmbeddedResource = " ; exw.ReportColor.rdlc"

Me.ReportViewer1.LocalReport.ReportEmbeddedResource = "exw.ReportColor.rdlc"

Me <字体大小= 2> .ReportViewer1.Location = System.Drawing.Point(0,0)

Me.ReportViewer1.Location = New System.Drawing.Point(0, 0)

Me .ReportViewer1.Name = " ReportViewer1"

Me.ReportViewer1.Name = "ReportViewer1"

.ReportViewer1.Size = New System.Drawing.Size(742,516)

Me.ReportViewer1.Size = New System.Drawing.Size(742, 516)

Me .ReportViewer1.TabIndex = 0

Me.ReportViewer1.TabIndex = 0

'

'

'exwDataSet

'exwDataSet

'

'

Me .exwDataSet.DataSetName = " exwDataSet"

Me.exwDataSet.DataSetName = "exwDataSet"

Me .exwDataSet.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema

Me.exwDataSet.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema

'

'

'ViewReportColorBindingSource

'ViewReportColorBindingSource

'

'

Me .ViewReportColorBindingSource.DataMember = " ViewReportColor"

Me.ViewReportColorBindingSource.DataMember = "ViewReportColor"

Me .ViewReportColorBindingSource.DataSource = Me .exwDataSet

Me.ViewReportColorBindingSource.DataSource = Me.exwDataSet

'

'

'ViewReportColorTableAdapter

'ViewReportColorTableAdapter

'

'

Me .ViewReportColorTableAdapter.ClearBeforeFill = True

Me.ViewReportColorTableAdapter.ClearBeforeFill = True

'

'

'ReportColor

'ReportColor

'

'

Me .AutoScaleDimensions = 系统.Drawing.SizeF(6.0!,13.0!)

Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)

Me 。 AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font

Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font

Me 。 ClientSize = System.Drawing.Size(742,516)

Me.ClientSize = New System.Drawing.Size(742, 516)

Me .Controls.Add( Me .ReportViewer1)

Me.Controls.Add(Me.ReportViewer1)

Me .Name = " ReportColor"

Me.Name = "ReportColor"

Me .Text = " ReportColor" ;

Me.Text = "ReportColor"

CType Me .exwDataSet,System.ComponentModel.ISupportInitialize)。EndInit()

CType(Me.exwDataSet, System.ComponentModel.ISupportInitialize).EndInit()

CType Me .ViewReportColorBindingSource,System.ComponentModel.ISupportInitialize).EndInit()

CType(Me.ViewReportColorBindingSource, System.ComponentModel.ISupportInitialize).EndInit()

Me .ResumeLayout( False

Me.ResumeLayout(False)

结束 Sub

End Sub

朋友 WithEvents ReportViewer1 As Microsoft.Reporting.WinForms.ReportViewer

Friend WithEvents ReportViewer1 As Microsoft.Reporting.WinForms.ReportViewer

朋友 WithEvents ViewReportColorBindingSource As System.Windows.Forms.BindingSource

Friend WithEvents ViewReportColorBindingSource As System.Windows.Forms.BindingSource

朋友 WithEvents exwDataSet As exw.exwDataSet

Friend WithEvents exwDataSet As exw.exwDataSet

朋友 WithEvents ViewReportColorTableAdapter As exw.exwDataSetTableAdapters.ViewReportColorTableAdapter

Friend WithEvents ViewReportColorTableAdapter As exw.exwDataSetTableAdapters.ViewReportColorTableAdapter

End Class

End Class

 

推荐答案

你有没有解决这个问题?我有完全相同的问题(仅在C#中),第一次调用有效,但没有其他。

Did you ever get this resolved? I'm having the exact same problem (only in C#) where the first invocation works, but no others.

谢谢,

Spencer


这篇关于报告查看器在MDI winform中崩溃(仅在生产中)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆