Ethan Schofer
Ethan Schofer

Reputation: 1848

ReportViewer Control Version Conflict

I am having a version problem with the ReportViewer Control. I am using visual studio 2010, but I think I need to use the 2005 report viewer because I am using SQL 2005. So, I set the webconfig file to point to the 2005 ReportViewer .dlls, everything works once, then VS edits the web.config to point to the 2010 versions of the dlls. Here is the relevant web config file sections set what I think is correctly:

<httpHandlers>
  <add path="elmah.axd" verb="POST,GET,HEAD" type="Elmah.ErrorLogPageFactory, Elmah" />
  <add path="Reserved.ReportViewerWebControl.axd" verb="*" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
    validate="false" />
</httpHandlers>

<compilation>
  <assemblies>
    <add assembly="Microsoft.ReportViewer.WebForms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
    <add assembly="Microsoft.ReportViewer.Common, Version=8.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
  </assemblies>
  <buildProviders>
    <add extension=".rdlc" type="Microsoft.Reporting.RdlBuildProvider, Microsoft.ReportViewer.WebForms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
  </buildProviders>
</compilation>

<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=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</handlers>

So, after running it and it working a few times, it automatically changes the version of the http handler to 10.0.0.0. How can I prevent this?

Upvotes: 3

Views: 14830

Answers (3)

Luke Whyte
Luke Whyte

Reputation: 31

It is possible to access SQL reports with a win forms app. developed using VS2010 with the ReportViewer Component Version=9.0.0.0.

Here are the steps:

To access SQL 2005 reports, you are going to have to use Version=9.0.0.0 of the report viewer component, as stated above. So you will need this in the .aspx page which you want to render the report or in a master page which it inherits:

Register assembly="Microsoft.ReportViewer.WebForms, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" namespace="Microsoft.Reporting.WebForms" tagprefix="rsweb"

And this

    <form id="foo" runat="server">
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <rsweb:ReportViewer ID="ReportViewer1" runat="server" ProcessingMode="Remote" Width="950px"
                    Height="600" BorderColor="Gainsboro" BorderStyle="Solid" BorderWidth="1px">
        <ServerReport ReportPath="/foo/foo/FooReport"
                ReportServerUrl="http://foo/ReportServerSQL2005" />
    </rsweb:ReportViewer>
…

You might have to change references to any other version of the ReportViewer Component in the web.conig as well because VS2010 and newer versions are going to default to new versions of the ReportViewer Component

e.g.

<add extension=".rdlc" type="Microsoft.Reporting.RdlBuildProvider, Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />

Change to

<add extension=".rdlc" type="Microsoft.Reporting.RdlBuildProvider, Microsoft.ReportViewer.WebForms, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />

Just search the entire solution for Version=8.0.0.0 and Version=10.0.0.0 etc. and make changes to both the Version= and PublicKeyToken=

You are also going to need a reference in your project to the reportviewer component 9.0.0.0, from the .net tab and remove any references to any other version.

It’s worth noting that when using .aspx pages which have both source and design views in VS, it will say Error Creating Contol – ReportViewer1, in the Design view. From what I have read, this is a bug with the component but it works anyway in all major browsers.

Also, if you are going to drag the component from the tools onto the design surface, you are most probably going to need to add the 9.0.0.0 version and ensure that it is this one that you use.

I previously answered this question here:

http://forums.asp.net/p/1985629/5691326.aspx?VS2010+ReportViewer+with+SQL+2005

However, my application is .NET 3.5 MVC2 application but I was still able to get it to render SQL2005 reports, after some considerable effort.

Ideally you should update your 2005 SQL report services to 2008, however, make sure that everything still works by creating a copy/backing up first because there is no going back. Once you have achieved this, all of the above becomes unnecessary, for us this was just an interim solution.

Upvotes: 1

Kevin Hogg
Kevin Hogg

Reputation: 1781

What is written to the web.config is defined by the references you use in the project.

In my Visual Studio 2008 project, I have the following references:

  • Microsoft.ReportViewer.Common.dll (Version 9.0.0.0)
  • Microsoft.ReportViewer.WebForms.dll (Version 9.0.0.0)

So in my config I see:

<system.web>
  ...
  <compilation>
    ...
    <buildProviders>
      <add extension=".rdlc" type="Microsoft.Reporting.RdlBuildProvider, Microsoft.ReportViewer.Common, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />        
    </buildProviders>
  </compilation>
  ...
  <httpHandlers>
    <add verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" validate="false"/>
  </httpHandlers>

When I look at the available project references I have three:

  • Version 8.0.0.0
  • Version 9.0.0.0
  • Version 10.0.0.0

I assume this is because I have Visual Studio 2005, 2008, and 2010 installed, but perhaps installing the individual report viewer redistributables would offer the same selection:

N.B. I've made best guesses at the version numbers; if you know better please correct me.

Upvotes: 3

IvanH
IvanH

Reputation: 5139

It is not an exact answer to your question but probably the solution.
There is no need to use older version of report viewer. It is independent on the server. Especially with .rdlc (client reports) you provide only data and report does not know the server.

Upvotes: 1

Related Questions