基础 class 包含字段 'report',但其类型 (Microsoft.Reporting.WebForms.ReportViewer) 是

The base class includes the field 'report', but its type (Microsoft.Reporting.WebForms.ReportViewer) is

我很绝望。我有这个页面,其中有一个直到几天前才有效的报告查看器。我没有更改我的 webconfig 或其他任何东西,但我现在收到此错误。这是我的 ASP.NET 代码:

<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="RisultatoStampaPdf.aspx.cs" Inherits="Fatture.Pagine.StampaDocumenti.RisultatoStampaPdf" %>

<%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
---code---

</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="BodyContent" runat="server">
    <div align="center">
        <h4>Premere il pulsante "Salva" e scegliere il formato desiderato</h4>
        <asp:Label ID="lblErrore" runat="server" Text=""></asp:Label>
        <rsweb:ReportViewer runat="server" ID="report" Font-Names="Calibri" Font-Size="12pt" WaitMessageFont-Names="Calibri" WaitMessageFont-Size="14pt" Width="740px" Height="500px">
            <LocalReport ReportPath="ReportFatture.rdlc">
                <DataSources>
                    <rsweb:ReportDataSource DataSourceId="ObjectDataSource2" Name="DataSet2" />
                </DataSources>
            </LocalReport>
        </rsweb:ReportViewer>
        <asp:ObjectDataSource ID="ObjectDataSource2" runat="server" OldValuesParameterFormatString="original_{0}" SelectMethod="GetData" TypeName="Fatture.DataSet2TableAdapters.DataTable1TableAdapter">
            <SelectParameters>
                <asp:Parameter Name="id_documento" Type="Int64" />
                <asp:Parameter Name="id_cliente" Type="Int64" />
            </SelectParameters>
        </asp:ObjectDataSource>
        <br />
        <asp:Button ID="btnReindirizza" class="btn btn-info" runat="server" Text="Torna indietro" OnClick="btnReindirizza_Click" />
        <hr />
    </div>
</asp:Content>

我正在使用 .NET Framework 4.51。

我找到了一个似乎有道理的答案:

尝试添加引用:Microsoft.Reporting.WebForms 之后,如果您遇到另一个错误,请尝试比较 <%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=11.0.0.0 和参考文献中所写的版本补充一下,如果有差异就把版本改成Microsoft.ReportViewer.WebForms.

的版本

希望对您有所帮助。 这是一个 link: https://mohamedelkassas.wordpress.com/2014/04/21/the-base-class-includes-the-field-xxx-but-its-type-microsoft-reporting-webforms-reportviewer-is-not-compatible-with-the-type-of-control-microsoft-reporting-webforms-reportviewer/

还有另一个解决方案:http://snahta.blogspot.co.il/2012/01/microsoftreportingwebformsreportviewer.html