Problem
You want to use a newer version of ExcelWriter or WordWriter with OfficeWriter’s Reporting Services integration. A common scenario is upgrading to an intermediate build of ExcelWriter or WordWriter which fixes a bug or adds a new feature.
To provide context, OfficeWriter’s Reporting Services integration consists of the following components:
- ExcelWriter (SoftArtisans.OfficeWriter.ExcelWriter.dll)
- WordWriter (SoftArtisans.OfficeWriter.WordWriter.dll)
- A custom rendering extension (SoftArtisans.OfficeWriter.RS2008.dll for SQL Server Reporting Services 2008)
When upgrading to a different version of ExcelWriter or WordWriter, normally you also have to upgrade to the matching version of the custom rendering extension. This is because the custom rendering extension is built against a specific version of ExcelWriter and WordWriter and only works with that version. If the version of ExcelWriter or WordWriter does not match the version of the custom rendering extension, you will get this error when exporting the report using ExcelWriter or WordWriter:
Could not load file or assembly ‘x’ or one of its dependencies. The located assembly’s manifest definition does not match the assembly reference.
If you are performing a regular upgrade in which you replace the custom rendering extension DLL as well as the ExcelWriter or WordWriter DLL, use the manual installation instructions as a guideline.
However, if there are no changes to the custom rendering extension, it is convenient to use the same custom rendering extension DLL and replace just the ExcelWriter or WordWriter DLL. This approach also allows you to easy test any version of the ExcelWriter or WordWriter DLL. In this case, follow the below instructions.
Solution
To upgrade the ExceWriter or WordWriter DLL without having to replace the custom rendering extension, you can create an assembly binding redirect so that request for the old DLL are redirected to the new DLL.
The solution is also applicable to any ASP.NET application for which you want to replace a dependent assembly with another version. Use the instructions below as guidelines for making modifications to the application’s web.config.
The process for creating an assembly binding redirect is slightly different for ExcelWriter and WordWriter, because by default WordWriter is installed into the Global Assembly Cache (GAC).
Upgrading ExcelWriter
1.
Navigate to the Reporting Services directory, typically `DRIVE:\Program Files\Microsoft SQL Server\MSRS10.MSSQLSERVER\Reporting Services’
2.
Copy SoftArtisans.OfficeWriter.ExcelWriter.dll to ReportServer\bin, replacing the existing DLL
3.
Determine the version of the new DLL; for example, 7.5.1.2770
4.
Edit ReportServer\web.config and add the following section under the
section:
XML Config Script
<configuration> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="SoftArtisans.OfficeWriter.ExcelWriter" publicKeyToken="f593502af6ee46ae" culture="neutral" /> <bindingRedirect oldVersion="7.5.0.1-7.5.1.9999" newVersion="7.5.1.2770"/> </dependentAssembly> </assemblyBinding> </runtime> </configuration>
Note: If there is an existing
section, add only the ” section inside it, so that there is only one assembly binding definition.
In the example above, set the newVersion
attribute to the version of the new DLL. Set the oldVersion
attribute to a single version or a range of versions which are to be mapped to the new version.
5.
Perform the same steps for ReportServer\bin\ReportingServicesService.exe.config
6.
Restart the Report Server
Upgrading WordWriter
If WordWriter is installed in the GAC, as done by the installer, you must also install the new DLL into the GAC. Because the GAC supports multiple versions of a DLL, you do not have to uninstall the old DLL. However, by using assembly binding redirect, you can force Reporting Services to use the new DLL. Follow the procedure below to upgrade WordWriter:
1.
Install the new DLL into the GAC using, for example, the gacutil tool.
2.
Navigate to the Reporting Services directory, typically ‘DRIVE:\Program Files\Microsoft SQL Server\MSRS10.MSSQLSERVER\Reporting Services’ Copy SoftArtisans.OfficeWriter.WordWriter.dll to ReportServer\bin
3.
Determine the version of the new DLL; for example, 4.5.1.1648
4.
Edit ReportServer\web.config and add the following section under the
section:
XML Config Script
<configuration> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="SoftArtisans.OfficeWriter.WordWriter" publicKeyToken="f593502af6ee46ae" culture="neutral" /> <bindingRedirect oldVersion="4.5.0.1-4.5.1.9999" newVersion="4.5.0.1567"/> </dependentAssembly> </assemblyBinding> </runtime> </configuration>
Note: If there is an existing section, add only the section inside it, so that there is only one assembly binding definition.
In the example above, set the newVersion attribute to the version of the new DLL. Set the oldVersion attribute to a single version or a range of versions which are to be mapped to the new version.
5.
Perform the same steps for ReportServer\bin\ReportingServicesService.exe.config
6.
Restart the Report Server
If WordWriter is not installed in the GAC, skip step 1 and follow steps 2-7 in the above procedure.