基类包含字段“report”,但其类型为(Microsoft.Reporting.WebForms.ReportViewer)。

5

我很着急。我有一个报表查看器页面,直到几天前都能正常工作。我没有更改我的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。


什么是错误信息? - israel altar
运行时错误,错误消息如下:基类包括字段“report”,但其类型(Microsoft.Reporting.WebForms.ReportViewer)与控件的类型(Microsoft.Reporting.WebForms.ReportViewer)不兼容。 - Nerd Nord
1
DLL有任何更改吗?Visual Studio的版本呢?这里是我找到的一个类似的答案:https://dev59.com/iHRA5IYBdhLWcg3wzhRY 请告诉我它是否有帮助。 - israel altar
1个回答

6
我找到了一个似乎有道理的答案: 尝试添加引用:Microsoft.Reporting.WebForms 之后,如果出现另一个错误,请比较<%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=11.0.0.0和你添加的引用中写的版本之间的差异,如果存在差异,请将版本更改为 Microsoft.ReportViewer.WebForms 的版本。 希望这可以帮助您。 以下是链接: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

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接