Visual-studio – ReportViewer Control Version Conflict

reporting-servicesreportviewersql-server-2005visual studiovisual studio 2010

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?

Best Answer

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.