Reporting - .NET Core Support (CTP, v18.1)

Reporting Team Blog
26 April 2018

The .NET Core framework is growing and adding more features with each release, so much so that we're getting many requests to support .NET Core in our products. However, one of the major limiting factors for us has been the lack of the System.Drawing assembly, something that's required for many of our controls. Luckily though, Microsoft has just released a version of System.Drawing for .NET Core, which means at last we can now work on migrating some of our libraries.

Well, I'm happy to announce that the powerful DevExpress Reporting tools can now run on .NET Core v2.1. Woohoo! That's right, you can now run DevExpress Reports within both Windows and Linux based environments.

This functionality is available as a CTP (community technology preview) in the v18.1 release. We're not finished with the porting the major features to the new .NET Core framework yet but rest assured, we're working on it.

In this post, I'll dive into the implementation details, limitations, future plans, and how you can start using DevExpress Reporting in your .NET Core applications.

Dependency: System.Drawing

As I mentioned above, many of our products are strongly tied to the System.Drawing assembly and the PrintDocument class. This dependency has made it hard for us to consider .NET Core for some of our products.

We thought about using third-party implementations like the CoreCompat/System.Drawing project. But we decided to wait for an official release from Microsoft before we started the massive effort to support the new .NET Core framework.

As it happened, last year Microsoft released the System.Drawing.Common 4.5.0-preview NuGet package. To be honest, in those early stages it wasn't terribly useful for us, and even now it's still only a "preview" version. It lacks too many features that we need, but it's a good beginning and it's at least something that we can use to start building the .NET Core version of our tools.

It's Alive!

So we got busy and started to port our tools to the .NET Core platform. And after:

We now have a version of XtraReports that works on .NET Core v2.1! It's so exciting that I had to say it twice.

Note: Please use .NET Core v2.1+ as it contains this bug fix that's necessary for XtraReports.

Challenges

Now let me tell you about some of the issues we ran into and how we solved them.

New Item Template

Getting around the System.Drawing assembly issue was big but it wasn't the only issue.

Our next major hurdle was that the main XtraReport class is a descendant of the System.ComponentModel.Component class. And the .NET Core framework does not include the System.ComponentModel assembly and therefore the necessary class. This would have prevented us from displaying the Report Designer in Visual Studio.

So our devs brainstormed a few ideas like running a separate web application (e.g., using IIS Express) with the Web Report Designer. This would allow you to build and design a report then store its layout. However, this approach was too complicated and besides, we came up with a better idea that's more elegant.

We implemented a new "DevExpress v18.1 Report (.NET Standard)" Item Template that adds a blank report template in an XML format to your .NET Core project:

Once you add this item to a project, then Visual Studio will automatically add a dependency to the necessary DevExpress.Reporting.Core NuGet package.

Note: Make sure that this package has been successfully restored because the report designer window will not open until the package is restored.

Report Designer

Then we needed a way to bring up the Report Designer in Visual Studio when someone wanted to edit/create an XtraReport. Luckily, we found a way using Visual Studio's internals to handle the double-click event on the project item. So Double-clicking this report template or selecting the "Open" context menu command in Visual Studio invokes the modal window with the fully-functional desktop Report Designer that enables you to design the report in the manner that you're used to:

ASP.NET Core Integration

Once you have finished designing your report, click the "Save" toolbar button to store the changes in the layout. After that, follow the steps described in this ASP.NET Core Reporting help article, it will help you integrate the Document Viewer or Web Report Designer into your application.

Alternatively, you can use our new "Project Template Item" that creates a new ASP.NET Core Reporting application with the Document Viewer and Web Report Designer already setup. In fact, we have two templates where the first one creates an app with a Bootstrap based theme and the second one uses the Angular framework:

This project template automatically adds a dependency to the DevExpress.AspNetCore.Reporting package. This package now includes two set of assemblies: one for .NET Core and other for .NET Framework (full). Previously, we had implemented support for ASP.NET Core applications targeting only the full version of .NET Framework (e.g. you were able to use a separate back-end to generate report documents).

Now, Visual Studio will automatically reference the corresponding assemblies within your project, depending on the target platform.

Check out this Knowledgebase Article to learn more details.

Docker Support

I'd like to highlight our Docker support. Say for example we took our newly created XtraReports on .NET Core project and added it to a Docker container. Would it work? Yes!

We tested this functionality using the 'microsoft/aspnetcore:2.0' Linux Image. Simply add the following lines into your Dockerfile and you'll be able to generate an XtraReport document in your container:

...
 FROM microsoft/aspnetcore:2.0 AS base
 RUN apt-get update
 RUN apt-get install -y libgdiplus libc6-dev
 ...

Refactoring: DevExpress.XtraReports.Web

While coding for .NET Core support, we noticed that the DevExpress.XtraReports.Web assembly forces an application developer to reference resources that are specific to other platforms (e.g., the source code of ASPxReportDesigner, ASPxWebDocumentViewer, ASPxDocumentViewer, and ASPxQueryBuilder controls and other related Web Forms and MVC-specific classes).

We saw an opportunity to refactor and improve our .NET Core support. We extracted the source code of these components (and the rest of specific classes) into a separate assembly called DevExpress.XtraReports.v18.1.Web.WebForms. So now the DevExpress.XtraReports.Web assembly only contains the cross-platform classes and resources that are used in any supported web platform whether it is ASP.NET, MVC, or ASP.NET Core.

Breaking Change

We also optimized the list of dependencies for each Reporting NuGet package. This is a positive change for the Reporting products but it does cause a minor breaking change. You can read a complete breaking change description here: BC4270.

This breaking change can easily be fixed by using our Project Converter which will add a reference to the required assembly when migrating to v18.1.

Limitations

Alas, there are some limitations that we still need to address, mainly:

  1. The XRRichText control is not available
  2. The PrintableComponentContainer control is not available
  3. The ObjectDataSource component cannot obtain the data source schema from an assembly built against the .NET Core platform (only .NET Standard and full .NET Framework)
  4. Linux-based environments are not able to generate 3D Charts that rely on the OpenGL library

Our goal is to solve the top three items so that we can proceed to the final version. Rest assured, we're working on them for a future release. However, the following list of features likely will not be implemented (due to platform restrictions):

  • Report Scripts are not supported
  • CodeDom serialization functionality is not supported
  • A report cannot be opened by Web Document Viewer's default resolver using the fully qualified type name in ASP.NET Core applications

We will consider if there's any workarounds or solutions to provide this missing functionality.

Future Plans

Our long-term vision is to provide a completely consistent set of features regardless of the platform you choose for reporting. Therefore, we're going to constantly improve the .NET Core support in the context of the next release cycle.

We'd love to hear your feedback about the XtraReports .NET Core support. Please leave a comment below, thanks.


Email: mharry@devexpress.com

Twitter: @mehulharry

Free DevExpress Products - Get Your Copy Today

The following free DevExpress product offers remain available. Should you have any questions about the free offers below, please submit a ticket via the DevExpress Support Center at your convenience. We'll be happy to follow-up.
No Comments

Please login or register to post comments.