Skip to content

Maintaining Legacy Support For RDLC Reports When Facing DLL Hell

It’s a fact of life. If you are a C# developer you have or will have to work with Microsoft’s Report Viewer and RDLC reports. Even though we are into our second year of Visual Studio 2019, RDLC reports are still relevant. Check the Nuget repository. It still has over 1500 downloads a days so it is apparent it is still used in development. Whether you just got tasked with re-designing some reports or need a reporting mechanism in your project, continue on to learn the common pitfalls with Visual Studio currently.

Particularly DLL hell when attaching entities to your reports.

Making sure you have the right tooling

There are two things you need to make sure you have in place before you can start designing RLDC reports. You will first need to make sure you have the right Nuget package.

For WinForm projects, you will need the the WinForms reporting package. Make the install easy with the Nuget Package Manager.

PM> Install-Package Microsoft.ReportingServices.ReportViewerControl.WinForms 

For any other project, you will need the WebForms version.

PM> Install-Package Microsoft.ReportingServices.ReportViewerControl.WebForms 

Out of the box, Visual Studio does not have a WYSIWYG editor for reports. Only XML development is available. To get this added capability we also need install the Microsoft RDLC Report Designer extension. You can install it from Visual Studio or from the browser.

To install with Visual Studio, go to the top menu.

Extensions -> Manage Extensions

In the top search, search “rdlc” and install Microsoft RDLC Report Designer.

You can also install from the browser by downloading from here. Once downloaded, you can just double click and install the VSIX file.

In both cases, you will have to restart Visual Studio to use.

XML Headings

If you have very old RDLC reports you may have namespace issues. You may have to update the XML namespaces before Visual Studio will load the file. Open up your RDLC report in an text editor like VSCode. Then make sure you have these namespaces as your Report attributes.

<Report 
    xmlns="http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition" 
    xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
<...>
</Report>

DLL Hell

If you have a dependency that relies on a version of System.ComponentModel.Annotations higher that 4.2, you are going to run into problems.

The Data Source Configuration Wizard relies on this version in order to work.

Here are the steps on wiring up a library class to the RLDC file.

After configuring for an object, we select our class and finish.

But we are met with the following error!

In this project, I have a Entity Framework core Nuget package that relies on version 4.70. So this version is not installed. In order to fix this, we need to get the correct version.

Download the the 4.1.0 version from Nuget.

https://www.nuget.org/api/v2/package/System.ComponentModel.Annotations/4.1.0

Change the downloaded file extension to .ZIP and unzip the archive. Then grab the following DLL location and put it in your project file structure so we can reference.

\lib\netstandard1.4\System.ComponentModel.Annotations.dll

We can now reference the correct DLL in our project.
If you don’t how now to reference a DLL in Visual Studio you can can learn here.

When attaching our object, we will need to trick Visual Studio into only seeing the correct System.ComponentModel.Annotation DLL while it does it. To do this, we:

Delete any data sources in our properites.

Then click on “Show all files” in the Solutions Explorer.

Now delete the “bin” and “obj” folders.

You should now be able to redo the prior steps to set a data source for your class.

Not ideal

Although Report Viewer has its problems, in some cases is the best option. It is built into .Net, it’s free, a robust template system and it is the only reporting service for .NET that offers a WYSIWYG editor. Sometimes the pitfalls don’t overcome the benefits and this case, RDLCs still rules the ecosystem.

Hopefully these tips help you if you have to work with them.

I have been programming for 7 years with over 10 years of systems administration. This is my blog to write about technology, current events, code, spread awareness, rant and rave and write the wrongs of the past. I am into new technology, programming, archery, turntablism, disc golf and rally racing.

Comments are closed.