Search code examples
c#asp.net.netreportviewer

Unable to view SQL Server mobile report in asp.net report viewer


I am unable to see report viewer control in UI post button click and also in aspx I am getting the below error message in design view.

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>

Code Behind:

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)
        {

        }
    }        
}

In web.config file I have added the below lines under system.webServer tag

<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>

I don't have access to the URL (http://Modile/Reports) I am using here and not sure if that is the issue. Can anyone help me this one?


Solution

  • I found the solution and the issue was with the report viewer version 10 which I was using. I also gave a try with report viewer 12 and it still didn't work. But reportviewer version 11 worked perfectly and we can get them in the below link.

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

    We need to add this assembly tag in web config file.

    <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>
    

    Register Assembly in aspx page will look like this once we drag and drop the report viewer control.

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