XtraReport.FromFile(String, Boolean) Method

Loads the report definition from the specified REPX file.

Namespace: DevExpress.XtraReports.UI

Assembly: DevExpress.XtraReports.v18.2.dll


public static XtraReport FromFile(
    string path,
    bool loadState = true
Public Shared Function FromFile(
    path As String,
    loadState As Boolean = True
) As XtraReport


Type Name Description
String path

A String value, specifying the full path (including the file name and extension) to the REPX or XML file.

Boolean loadState

true to restore the property values of a report along with the settings applied to its elements (bands and controls); false to load only the base type settings of the specified report.


Type Description

An XtraReport class (or its descendant, the type of which is specified in the REPX or XML file).


Use the FromFile method to restore a report from its definition file (stored in the standard REPX, or a custom XML format).


Deserialization of reports obtained from untrusted parties can trigger execution of malicious code that can either be directly embedded into the report definition, or contained in an external assembly referenced by the report.

To avoid this, we recommend that you use XML serialization instead of CodeDOM and prevent any untrusted third-party libraries from becoming available on the server.

When a reporting application is deployed under the Medium Trust permission level, XML serialization is the only option to save reports (CodeDOM serialization is not supported in such environment).

To be able to restore the report class settings, this method must locate the associated report type based on which the specified report definition file was created. This type is searched for in the following assemblies.

  1. in the current assembly (from which the FromFile method is called);
  2. in the assembly (an EXE or DLL file) which produced the report definition file. Its path is also mentioned in the definition file's header;
  3. in the assemblies referenced by the current assembly.

When this method fails to locate the originating class type, it creates a new XtraReport class instance.

Calling this method with its loadState parameter set to true will restore all custom property values of both a report and its elements.


Setting the loadState parameter to true is preferred in most scenarios, because the report specified in the definition file can be of the XtraReport type (e.g., when a report was saved using the Visual Studio report designer). In this case, setting the loadState parameter to false will result in an empty report being restored.


This example demonstrates how to restore a report definition from a file by using the XtraReport.FromFile method.

In the following code, this method is called with its loadState parameter set to true, restoring all custom property values of both a report and its elements.

To run the following code, the application must successfully locate the assembly based on which the specified XtraReport1.repx file was created (either in the original project folder, among the assemblies referenced by the example, or in the GAC).

using System;
using System.Windows.Forms;
using DevExpress.XtraReports.UI;
// ...

private void Form1_Load(object sender, EventArgs e) {
    // Restore a report from a file.
    XtraReport report = XtraReport.FromFile(@"..\\..\\XtraReport1.repx", true);

    // Show the report's Print Preview.
    ReportPrintTool printTool = new ReportPrintTool(report);
See Also