Articles in this section
Category / Section

How to use the code class in WINRT?

2 mins read

The WinRT ReportViewer has some limitations in compiling the VB code functions due to the following reasons:

  1. The reports custom code needs to be compiled against the Microsoft.VisualBasic assemblies and that is not possible in the WinRT platform.
  2. The assemblies can be compiled in the server side by using the Microsoft.VisualBasic assemblies and loading it in the WinRT; but this also has the similar problem in loading assemblies and does not support the WinRT platform.

In order to use the reports Code and to avoid these limitations, the WINRT ReportViewer has an alternative solution for the custom Code function support. To use this option, reports custom codes need to be written and compiled in the application.

Steps to run the RDL/RDLC custom code in the WINRT ReportViewer:

  1. Create a new blank Windows Application.

The image illustrates the New Windows Application

Figure 1: New Windows Application

  1. Add the necessary assemblies to the application.

The image illustrates the list of necessary assemblies added

Figure 2: Necessary assemblies added

  1. Create the ReportViewer from XAML. The following code sample shows the same.


     <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <Reports:SfReportViewer Name="ReportViewer"/>


  1. Load the report stream to the ReportViewer and add the DataSource values as given in the following code.


Assembly assembly = typeof(MainPage).GetTypeInfo().Assembly;
                Stream reportStream = assembly.GetManifestResourceStream("CustomCode.Assets.Pivot Table.rdlc");
                this.ReportViewer.ProcessingMode = ProcessingMode.Local;
                this.ReportViewer.DataSources.Add(new ReportDataSource { Name = "Sales", Value = new AdventureWorks().GetData() });
  1. Add a new class Code.cs to the application and specify the namespace Syncfusion.Reports.Helper (for example, namespace Syncfusion.Reports.Helper).



 The namespace of the newly created class must be Syncfusion.Reports.Helper (namespace Syncfusion.Reports.Helper)


  1. Add a new static class with the name of the Code (for example, public static class Code).
  2. Add the methods with the Static type that is used in your report code functions (for example, GetValueStatus).


namespace Syncfusion.Reports.Helper
    public static class Code
        public static string GetValueStatus(string value)
            double dataValue = Convert.ToDouble(value);
             if (dataValue >= 80000)
                return "High Profit";
            else if (dataValue >= 40000)
                return "Moderate Profit";
                return "Average Profit";
  1. The executing assembly must be added to the ReportViewer’s Assemblies API in order to process the custom code in the WINRT ReportViewer.


  1. You can pass a dataset field, Sales, to this function in an expression.


  1. Build and Run the application.

Sample Link:


Did you find this information helpful?
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment