无法在asp.net报表查看器中查看SQL Server移动报表

时间:2016-10-07 06:00:08

标签: c# asp.net .net reportviewer

我无法在UI帖子按钮单击和aspx中看到报表查看器控件我在设计视图中收到以下错误消息。

Error Creating Control - ReportViewer1Failed to create designer 'Microsoft.Reporting.WebForms.ReportViewer, Microsoft.ReportViewer.WebForms, 
Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

ASPX:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ExportReportToPDF.aspx.cs"
Inherits="ExportReportss.ExportReportToPDF" EnableEventValidation="false" %>

<%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, 
PublicKeyToken=b03f5f7f11d50a3a"
Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
    <br />
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <asp:Button ID="btnGetReport" runat="server" Text="GetReport"     OnClick="btnGetReport_Click" />
        <rsweb:ReportViewer ID="ReportViewer1" runat="server">
        </rsweb:ReportViewer>
    </div>
</form>
</body>
</html>

代码背后:

public partial class ExportReportToPDF : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void btnGetReport_Click(object sender, EventArgs e)
    {
        try
        {
            ReportViewer1.ProcessingMode = ProcessingMode.Remote;
            ReportViewer1.ServerReport.ReportServerUrl = new Uri("http://Modile/Reports");
            ReportViewer1.ServerReport.Refresh();
        }
        catch (Exception ex)
        {

        }
    }        
}

在web.config文件中,我在system.webServer标记

下添加了以下行
<handlers>
  <add name="ReportViewerWebControlHandler" preCondition="integratedMode"     verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</handlers>

我无法访问我在此处使用的网址(http://Modile/Reports),并且不确定这是否是问题所在。任何人都可以帮我这个吗?

2 个答案:

答案 0 :(得分:4)

我找到了解决方案,问题在于我正在使用的报表查看器版本10。我还尝试了报告查看器12,它仍然没有工作。但是reportviewer 11版本工作得很好,我们可以通过以下链接获取它们。

 https://www.microsoft.com/en-in/download/details.aspx?id=35747

我们需要在Web配置文件中添加此程序集标记。

<assemblies>
    <add assembly="Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
    <add assembly="Microsoft.ReportViewer.Common, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
    <add assembly="Microsoft.Build.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
    <add assembly="System.Management, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
</assemblies>
一旦我们拖放报表查看器控件,

在aspx页面中注册程序集将如下所示。

<%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>

答案 1 :(得分:2)

如果您的visual studio版本是4.6,则从Reference中添加Microsoft.ReportViewer.WebForms 12.0.0.0和Microsoft.ReportViewer.WinForms 12.0.0.0的参考,并将Register Assembly版本更改为12.0.0.0。

在aspx页面中,它看起来像这样:

<%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=12.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>

在web.config中:

<system.web>
<httpHandlers>
  <add path="Reserved.ReportViewerWebControl.axd" verb="*" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=12.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"
    validate="false" />
</httpHandlers>
<assemblies>
    <add assembly="Microsoft.ReportViewer.WebForms, Version=12.0.0.0, Culture=neutral, PublicKeyToken=89845DCD8080CC91"/>
    <add assembly="Microsoft.ReportViewer.Common, Version=12.0.0.0, Culture=neutral, PublicKeyToken=89845DCD8080CC91"/>
    <add assembly="Microsoft.Build.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
</assemblies>
<buildProviders>
    <remove extension=".rdlc" />
    <add extension=".rdlc" type="Microsoft.Reporting.RdlBuildProvider, Microsoft.ReportViewer.WebForms, Version=12.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
</buildProviders>
</system.web>


<system.webServer> 
  <handlers>
  <remove name="ReportViewerWebControlHandler"/>
  <add name="Reenter code hereportViewerWebControlHandler" preCondition="integratedMode" verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=12.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
  </handlers>
 </system.webServer>