Upgrade Microsoft Reports to support Visual Studio 2019 / 2022
Run through the following steps to upgrade a project using Microsoft Report Viewer Runtimes 9-13 to Sql Server Reporting Services 14 or 15.
Backup Visual Studio solution
Check Microsoft Report Designer is installed for Visual Studio 2019 (min version 15.3.1) or Visual Studio 2022 (min version 17.0.0)
Uninstall or manually remove the following assembly references (any versions: 9.0.0.0, 10.0.0.0, 11.0.0.0, 13.0.0.0) from project
- Install Microsoft.ReportingServices.ReportViewerControl.WebForms OR Microsoft.ReportingServices.ReportViewerControl.Winforms which includes both updated dll's
ASP.NET - For Target Runtime .NET 4.5.2 (14.0.0.0)
Install-Package Microsoft.ReportingServices.ReportViewerControl.WebForms -Version 140.1000.523
ASP.NET - For Target Runtime .NET 4.6 and above (15.0.0.0)
Install-Package Microsoft.ReportingServices.ReportViewerControl.WebForms -Version 150.1537.0
WinForms - For Target Runtime .NET 4.5.2 (14.0.0.0)
Install-Package Microsoft.ReportingServices.ReportViewerControl.Winforms -Version 140.1000.523
WinForms - For Target Runtime .NET 4.6 and above (15.0.0.0)
Install-Package Microsoft.ReportingServices.ReportViewerControl.Winforms -Version 150.1537.0
This will install the following assemblies to the project...
- Microsoft.ReportViewer.Common.dll
- Microsoft.ReportViewer.DataVisualization.dll
- Microsoft.ReportViewer.Design.dll
- Microsoft.ReportViewer.ProcessingObjectModel.dll
- Microsoft.ReportViewer.WebDesign.dll
- Microsoft.ReportViewer.WebForms.dll
- Microsoft.ReportViewer.WinForms.dll
- In ASP.NET - The App_Code folder will have new SqlServerTypes directory containing Loader.cs.
and include package Microsoft.SqlServer.Types.14.0.314.76
This folder will also appear in any Library project the package is also installed in.
\SqlServerTypes\
- Loader.cs or Loader.vb
- readme.htm
\SqlServerTypes\x64\
- msvcr120.dll
- SqlServerSpatial140.dll
\SqlServerTypes\x86\
- msvcr120.dll
- SqlServerSpatial140.dll
If the App_Code directory is configured for VB.NET, a new VB class should be added called Loader.vb and the autogenerated Loader.cs can be removed from App_Code\SqlServerTypes.
Imports System
Imports System.IO
Imports System.Runtime.InteropServices
Namespace SqlServerTypes
Public Class Utilities
<DllImport("kernel32.dll", CharSet:=CharSet.Auto, SetLastError:=True)>
Public Shared Function LoadLibrary(ByVal libname As String) As IntPtr
End Function
Public Shared Sub LoadNativeAssemblies(ByVal rootApplicationPath As String)
Dim nativeBinaryPath = If(IntPtr.Size > 4, Path.Combine(rootApplicationPath, "SqlServerTypes\x64\"), Path.Combine(rootApplicationPath, "SqlServerTypes\x86\"))
LoadNativeAssembly(nativeBinaryPath, "msvcr120.dll")
LoadNativeAssembly(nativeBinaryPath, "SqlServerSpatial140.dll")
End Sub
Private Shared Sub LoadNativeAssembly(ByVal nativeBinaryPath As String, ByVal assemblyName As String)
Dim path = System.IO.Path.Combine(nativeBinaryPath, assemblyName)
Dim ptr = LoadLibrary(path)
If ptr = IntPtr.Zero Then
Throw New Exception(String.Format("Error loading {0} (ErrorCode: {1})", assemblyName, Marshal.GetLastWin32Error()))
End If
End Sub
End Class
End Namespace
Configuration
In ASP.NET update the web config for Target .NET 4.5.2 (Reporting Services 14.0.0.0)
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
https://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.5.2">
<assemblies>
<!-- All assemblies updated to version 14.0.0.0. -->
<add assembly="Microsoft.ReportViewer.Common, Version=14.0.0.0, Culture=neutral, PublicKeyToken=89845DCD8080CC91"/>
<add assembly="Microsoft.ReportViewer.DataVisualization, Version=14.0.0.0, Culture=neutral, PublicKeyToken=89845DCD8080CC91"/>
<add assembly="Microsoft.ReportViewer.Design, Version=14.0.0.0, Culture=neutral, PublicKeyToken=89845DCD8080CC91"/>
<add assembly="Microsoft.ReportViewer.ProcessingObjectModel, Version=14.0.0.0, Culture=neutral, PublicKeyToken=89845DCD8080CC91"/>
<add assembly="Microsoft.ReportViewer.WebDesign, Version=14.0.0.0, Culture=neutral, PublicKeyToken=89845DCD8080CC91"/>
<add assembly="Microsoft.ReportViewer.WebForms, Version=14.0.0.0, Culture=neutral, PublicKeyToken=89845DCD8080CC91"/>
<add assembly="Microsoft.ReportViewer.WinForms, Version=14.0.0.0, Culture=neutral, PublicKeyToken=89845DCD8080CC91"/>
</assemblies>
<buildProviders>
<!-- Version updated to 14.0.0.0. -->
<add extension=".rdlc"
type="Microsoft.Reporting.RdlBuildProvider, Microsoft.ReportViewer.WebForms, Version=14.0.0.0, Culture=neutral, PublicKeyToken=89845DCD8080CC91"/>
</buildProviders>
</compilation>
<httpRuntime targetFramework="4.5.2"/>
<httpHandlers>
<!-- Version updated to 14.0.0.0 -->
<add path="Reserved.ReportViewerWebControl.axd" verb="*"
type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=14.0.0.0, Culture=neutral, PublicKeyToken=89845DCD8080CC91"
validate="false"/>
</httpHandlers>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules runAllManagedModulesForAllRequests="true"/>
<handlers>
<!-- Version updated to 14.0.0.0 -->
<add name="ReportViewerWebControlHandler" verb="*" path="Reserved.ReportViewerWebControl.axd" preCondition="integratedMode"
type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=14.0.0.0, Culture=neutral, PublicKeyToken=89845DCD8080CC91"/>
</handlers>
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.SqlServer.Types" publicKeyToken="89845dcd8080cc91" culture="neutral" />
<bindingRedirect oldVersion="10.0.0.0-11.0.0.0" newVersion="14.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
Or Update Web config for Target .NET 4.6 and above (Reporting Services 15.0.0.0)
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
https://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.6">
<assemblies>
<!-- All assemblies updated to version 15.0.0.0. -->
<add assembly="Microsoft.ReportViewer.Common, Version=15.0.0.0, Culture=neutral, PublicKeyToken=89845DCD8080CC91"/>
<add assembly="Microsoft.ReportViewer.DataVisualization, Version=15.0.0.0, Culture=neutral, PublicKeyToken=89845DCD8080CC91"/>
<add assembly="Microsoft.ReportViewer.Design, Version=15.0.0.0, Culture=neutral, PublicKeyToken=89845DCD8080CC91"/>
<add assembly="Microsoft.ReportViewer.ProcessingObjectModel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=89845DCD8080CC91"/>
<add assembly="Microsoft.ReportViewer.WebDesign, Version=15.0.0.0, Culture=neutral, PublicKeyToken=89845DCD8080CC91"/>
<add assembly="Microsoft.ReportViewer.WebForms, Version=15.0.0.0, Culture=neutral, PublicKeyToken=89845DCD8080CC91"/>
<add assembly="Microsoft.ReportViewer.WinForms, Version=15.0.0.0, Culture=neutral, PublicKeyToken=89845DCD8080CC91"/>
</assemblies>
<buildProviders>
<!-- Version updated to 15.0.0.0. -->
<add extension=".rdlc"
type="Microsoft.Reporting.RdlBuildProvider, Microsoft.ReportViewer.WebForms, Version=15.0.0.0, Culture=neutral, PublicKeyToken=89845DCD8080CC91"/>
</buildProviders>
</compilation>
<httpRuntime targetFramework="4.6"/>
<httpHandlers>
<!-- Version updated to 15.0.0.0 -->
<add path="Reserved.ReportViewerWebControl.axd" verb="*"
type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=15.0.0.0, Culture=neutral, PublicKeyToken=89845DCD8080CC91"
validate="false"/>
</httpHandlers>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules runAllManagedModulesForAllRequests="true"/>
<handlers>
<!-- Version updated to 15.0.0.0 -->
<add name="ReportViewerWebControlHandler" verb="*" path="Reserved.ReportViewerWebControl.axd" preCondition="integratedMode"
type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=15.0.0.0, Culture=neutral, PublicKeyToken=89845DCD8080CC91"/>
</handlers>
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.SqlServer.Types" publicKeyToken="89845dcd8080cc91" culture="neutral" />
<bindingRedirect oldVersion="10.0.0.0-11.0.0.0" newVersion="14.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
Build the solution and confirm the whole project compiles.
Upgrade the reports to support the Visual Studio IDE if created in an older version of Visual Studio Report Designer.
Double click the report in Visual Studio and convert when prompted "Do you want to convert this Report". This will automatically update the XML to the current supported schema.
When the report has been upgraded, you must click Save to finalise the changes to the report file. A backup copy is automatically made of the original file and a new file is created in it's place.
Then when the report is viewed in an XML editor the following schema definition changes will have been made by the conversion tool.
On a report without report parameters
From: VS2013
<Report xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner"
xmlns:cl="http://schemas.microsoft.com/sqlserver/reporting/2010/01/componentdefinition"
xmlns="http://schemas.microsoft.com/sqlserver/reporting/2010/01/reportdefinition">
To: VS2019 / VS2022
<Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2010/01/reportdefinition"
xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
What a Default New VS2019 / VS2022 report uses
<Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition"
xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
On a report with report parameters
From: VS2013
<Report xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner"
xmlns:cl="http://schemas.microsoft.com/sqlserver/reporting/2010/01/componentdefinition"
xmlns="http://schemas.microsoft.com/sqlserver/reporting/2010/01/reportdefinition">
To: VS2019 / VS2022
<Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition"
xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
The conversion tool adds a ReportParametersLayout block if report has ReportParameters element. For example;
<ReportParametersLayout>
<GridLayoutDefinition>
<NumberOfColumns>1</NumberOfColumns>
<NumberOfRows>1</NumberOfRows>
<CellDefinitions>
<CellDefinition>
<ColumnIndex>0</ColumnIndex>
<RowIndex>0</RowIndex>
<ParameterName>Test</ParameterName>
</CellDefinition>
</CellDefinitions>
</GridLayoutDefinition>
</ReportParametersLayout>
If you click Cancel when prompted to convert the report, there is an option to manually Edit the schema.
It is possible to Edit the xml schema and downgrade the supported specification to allow the report to load in the current version of Visual Studio Report Designer.
Downgrade report from 2016 or 2010 to 2008 schema definition
If the Report was created in a newer unsupported version of the current Report Designer the upgrade will fail. The Report will need to be downgraded for the file to open in Visual Studio 2019.
Please try the following XML markup changes only if the automatic upgrade failed;
From: 2016 schema
<Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition"
xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
From: 2016 schema including default font family
<Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition"
xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner"
xmlns:df="http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition/defaultfontfamily"
MustUnderstand="df">
From: 2010 schema
<Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2010/01/reportdefinition"
xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
To: 2008 schema
<Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition"
xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
Then Downgrade the SSRS report by removing elements that are not used in the 2008 schema.
Remove the tag ReportSections but not any child elements for it
<ReportSections></ReportSections>
Remove the tag ReportSection but not any child elements for it
<ReportSection></ReportSection>
Remove the element ReportParametersLayout and all child elements (including GridLayoutDefinition)
<ReportParametersLayout></ReportParametersLayout>
If the report contains the default font attribute "df" remove the following also...
Remove the Report MustUnderstand="df" attribute if it has one.
Remove the Report xmlns:df attribute if it has one.
Remove the element df and all child elements if it has one.
- For WinForms - Include file in output directory
If the project is WinForms, to include the report in the output directory right click on the Report file and click Properties.
Change the file Properties Copy To Output Directory to "Copy if newer" and Save project.
- Finally: Build and Test
Once all changes have been saved, build the solution to confirm the project is correctly compiling using the SQL Server Reporting Services runtimes and then test processing an SSRS Local Report using your custom code.
Setting up SQL Server native assemblies for spatial data types
ASP.NET applications For ASP.NET applications, add the following line
of code to the Application_Start method in Global.asax.cs:
SqlServerTypes.Utilities.LoadNativeAssemblies(Server.MapPath("~/bin"));
Desktop applications For desktop applications, add the following line
of code to run before any spatial operations are performed:
SqlServerTypes.Utilities.LoadNativeAssemblies(AppDomain.CurrentDomain.BaseDirectory);
Report Viewer Control Versions
8.0 (2005) - 8.0.50727.42 - Visual Studio 2005
9.0 (2008) - 9.0.30729.1 - Visual Studio 2008
10.0 (2010) - 10.0.40219.1 - Visual Studio 2010
11.0 (2012) - 11.1.3452.0 - Visual Studio 2012/2013
12.0 (2014) for SQL Server 2014 - 12.0.2000.8 - SQL Server 2014
12.0 (2015 Report Viewer or using SSDT) - 12.0.2402.15 - Visual Studio 2015 (SSDT)
13.0 for SQL Server 2016 (NuGet) - 13.0.1700.305 - SQL Server 2016
13.0 for SQL Server 2016 - 13.0.x.x - SQL Server 2016 Feature Pack
14.0 (NuGet) - 14.0.1016.229 - Visual Studio 2017
14.0 (2017 SSDT) - 14.0.x.x - Visual Studio 2017 (SSDT)
15.0 (NuGet) - 15.0.1537.0 - Visual Studio 2017/2019/2022
15.0 (2017/2019 Report Designer Extension) - 15.0.1322.137 - VS 2017/2019 Report Designer
15.0 (2022 Report Designer Extension) - 15.0.1509.0 - VS 2022 Report Designer