关于asp.net:使用ReportViewer和Global.System.Diagnostics.DebuggerNonUserCodeAttribute的无限循环

Infinite Loop with ReportViewer and Global.System.Diagnostics.DebuggerNonUserCodeAttribute

我编写了一个简单的WebForm,其中包含1个文本框和一个ReportViewer(由Reoprt向导创建)。尝试执行报告时没有收到任何错误,但报告从未停止加载。我已经仔细检查了.rdlc文件(通过预览.xsd文件并显示预期的数据。因此,我在后面的代码中设置了一个断点,以查看是否可以确定问题所在。以某种方式,代码成功完成并刷新ReportViewer代码,然后进入Designer.vb文件以运行4个功能,然后再次返回ReportViewer代码。我不了解Designer.vb代码中发生了什么。我做错了吗?我将包括ASP.net,vb代码后面以及Designer.vb文件中的4个代码块。

ASP.net代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
    <%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/HRMaster.Master" CodeBehind="VacationSick_EmployeeReportByArea.aspx.vb" Inherits="CEI_PerformanceReviews.VacationSick_EmployeeReportByArea" %>
    <%@ Register assembly="Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" namespace="Microsoft.Reporting.WebForms" tagprefix="rsweb" %>

</asp:Content>

    </asp:Label>
    <p>
    </p>
   
    </asp:DropDownList>
   " SelectCommand="SELECT  DISTINCT PeriodYYYY
FROM    Ted.CafeWorks.dbo.FatzPeriodDates
WHERE   PeriodYYYY >= (DATEPART(YEAR, GetDate())-2)
ORDER BY PeriodYYYY DESC"></asp:SqlDataSource>
   
   
    </asp:ScriptManager>
    </asp:Label>
    <rsweb:ReportViewer ID="
rv_EmployeeReportByArea" runat="server" Font-Names="Verdana" Font-Size="8pt" style="z-index: 1; left: 29px; top: 280px; position: absolute; height: 400px; width: 710px" WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt">
        <LocalReport ReportEmbeddedResource="
CEI_PerformanceReviews.VacationSick_ReportByArea.rdlc">
            <DataSources>
                <rsweb:ReportDataSource DataSourceId="
ObjectDataSource2" Name="Dilbert_VacationSickByArea" />
            </DataSources>
        </LocalReport>
    </rsweb:ReportViewer>
   
        <SelectParameters>
           
        </SelectParameters>
    </asp:ObjectDataSource>
   
        <SelectParameters>
           
        </SelectParameters>
    </asp:ObjectDataSource>
</asp:Content>

后面的VB代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Imports Microsoft.Reporting.WebForms

Public Class VacationSick_EmployeeReportByArea
Inherits System.Web.UI.Page

'Declare Variables
Dim Choose_Year As String

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    'Default the Year in ddl to this year
    If (Page.IsPostBack) = False Then
        ddl_Year.SelectedValue = Now.Year
    End If

    'When the page loads, fill the report with the current year's data
    Choose_Year = ddl_Year.SelectedValue.ToString()
    rv_EmployeeReportByArea.LocalReport.ReportPath ="VacationSick\\VacationSick_ReportByArea.rdlc"
    Dim Param As New ReportParameter("Year","2014")
    rv_EmployeeReportByArea.LocalReport.SetParameters({Param})
    rv_EmployeeReportByArea.ServerReport.Refresh()
End Sub

执行文件Dilbert_VacationSickByArea.Designer.vb中的以下4个代码块,然后返回到ReportViewer的PageLoad代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<Global.System.Diagnostics.DebuggerNonUserCodeAttribute(),  _
         Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator","4.0.0.0")>  _
        Public Property ClearBeforeFill() As Boolean
            Get
                Return Me._clearBeforeFill
            End Get
            Set
                Me._clearBeforeFill = value
            End Set
        End Property


 <Global.System.Diagnostics.DebuggerNonUserCodeAttribute(),  _
         Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator","4.0.0.0")>  _
        Protected Friend ReadOnly Property Adapter() As Global.System.Data.SqlClient.SqlDataAdapter
            Get
                If (Me._adapter Is Nothing) Then
                    Me.InitAdapter
                End If
                Return Me._adapter
            End Get
        End Property


 <Global.System.Diagnostics.DebuggerNonUserCodeAttribute(),  _
         Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator","4.0.0.0")>  _
        Protected ReadOnly Property CommandCollection() As Global.System.Data.SqlClient.SqlCommand()
            Get
                If (Me._commandCollection Is Nothing) Then
                    Me.InitCommandCollection
                End If
                Return Me._commandCollection
            End Get
        End Property


 <Global.System.Diagnostics.DebuggerNonUserCodeAttribute(),  _
         Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator","4.0.0.0")>  _
        Protected Friend ReadOnly Property Adapter() As Global.System.Data.SqlClient.SqlDataAdapter
            Get
                If (Me._adapter Is Nothing) Then
                    Me.InitAdapter
                End If
                Return Me._adapter
            End Get
        End Property


 <Global.System.Diagnostics.DebuggerNonUserCodeAttribute(),  _
         Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator","4.0.0.0")>  _
        Protected Friend ReadOnly Property Adapter() As Global.System.Data.SqlClient.SqlDataAdapter
            Get
                If (Me._adapter Is Nothing) Then
                    Me.InitAdapter
                End If
                Return Me._adapter
            End Get
        End Property


尝试仅打印报告If Not Me.Page.IsPostBack

您还可以删除rv_EmployeeReportByArea.ServerReport.Refresh(),因为您使用的是LocalReport