Link to home
Start Free TrialLog in
Avatar of ybt
ybt

asked on

SSRS report preview problem in asp.net

ASP.NET C#
I'm trying to view ssrs report in reportviewer in webpage
got an error
Parser Error Message: Could not load file or assembly 'Microsoft.ReportViewer.WebForms, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
 pointing to this row:

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

Open in new window


my aspx code:

<%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
    Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WEB_ONE1.WebForm1" %>


<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
        <rsweb:ReportViewer ID="ReportViewer1" runat="server" Height="484px" Width="737px">
        </rsweb:ReportViewer>
    <div>
    
    </div>
    </form>
</body>
</html>

Open in new window


my cs code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.Reporting.WebForms;
using Microsoft.ReportingServices.WebServer;
using System.Web.Configuration;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;
using System.Web.Security;
using System.Resources;
using System.Globalization;
using System.Text;
using Microsoft.ReportingServices.WebServer;

namespace WEB_ONE1
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                // Set the processing mode for the ReportViewer to Remote
                ReportViewer1.ProcessingMode = ProcessingMode.Remote;

                ServerReport serverReport = ReportViewer1.ServerReport;

                // Set the report server URL and report path
                serverReport.ReportServerUrl = new Uri("http://lsmsql/ReportServer_LOVELLSQL");
                serverReport.ReportPath = "/Reports/Claim_Init_RPT";

                
                serverReport.GetParameters();

              
                ReportParameter key_no = new ReportParameter();
                key_no.Name = "key_no";
                key_no.Values.Add("121");
                ReportParameter title = new ReportParameter();
                title.Name = "title";
                title.Values.Add("title");

                ReportParameter userid = new ReportParameter();
                userid.Name = "userid";
                userid.Values.Add("user");

                ReportParameter pwd = new ReportParameter();
                pwd.Name = "pwd";
                pwd.Values.Add("*******");

                // Set the report parameters for the report
                ReportViewer1.ServerReport.SetParameters(
                  new ReportParameter[] { key_no, title, userid, pwd });

                ReportViewer1.DataBind();
            }

          
        }
    }
}

Open in new window


webconfig:
<?xml version="1.0"?>

<configuration>
  <appSettings>
    <add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
  </appSettings>
  <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=B03F5F7F11D50A3A"
        validate="false" />
    </httpHandlers>
    <compilation debug="true" targetFramework="4.5">
      <assemblies>
        <add assembly="Microsoft.ReportViewer.WebForms, Version=12.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
        <add assembly="Microsoft.ReportViewer.Common, Version=12.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
        <add assembly="Microsoft.Build.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
      </assemblies>
      <buildProviders>
        <add extension=".rdlc" type="Microsoft.Reporting.RdlBuildProvider, Microsoft.ReportViewer.WebForms, Version=12.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
      </buildProviders>
    </compilation>
    <httpRuntime targetFramework="4.5" />
  </system.web>
  <connectionStrings>
    <add name="DbConnString" connectionString="Data Source=LSMSQL\LOVELLSQL;Initial Catalog="";User ID="";Password=""" providerName="System.Data.SqlClient" />
    <add name="ExpanseConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Expanse.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient" />
  </connectionStrings>

   <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <handlers>
      <add name="ReportViewerWebControlHandler" preCondition="integratedMode" verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=12.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
    </handlers>
  </system.webServer>
</configuration>
ASKER CERTIFIED SOLUTION
Avatar of Misha
Misha
Flag of Russian Federation image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ybt
ybt

ASKER

I installed Microsoft.ReportViewer.2012.Runtime, but it shows version 11, So I changed my code to version=11 and still have the same error, During installation all .dll copied in bin directory automatically
Try to install Microsoft.ReportViewer.2012 instead of 11.
Avatar of ybt

ASKER

Thank you, finally I made it working
Glad to help you!