New to Telerik Reporting? Download free 30-day trial

TypeReferences Element Overview

This element was first introduced in the 2024 Q1 (18.0.24.305) Reporting version.

Defines a collection of type references used by the Reporting Engine to resolve the custom types permitted to be used during the design and processing stages. The assemblies used by the types in the TypeReferences section are loaded into the application domain if the type is successfully resolved, so it's not necessary to also declare the assembly in the assemblyReferences section.

XML-based configuration file:

<TypeReferences>
    <add />
    <clear />
    <remove />
</TypeReferences>

JSON-based configuration file:

"TypeReferences": [
],

The TypeReferences element was introduced to let you allow only specific types from restricted assemblies, i.e., assemblies not listed in the assemblyReferences element.

If you want to allow all the types from a DLL, use the assemblyReferences element. instead.

Attributes and Elements

The following sections describe attributes, child elements, and parent elements.

Attributes
  • typeName – mandatory string attribute. Specifies the full name of the type, i.e. namespace and class name.
  • assemblyName – mandatory string attribute. Specifies the name of the assembly that contains the type.
  • publicKeyToken – optional string attribute. Specifies the public key token of the assembly. Can be omitted or can have empty or null value.
Child Elements
  • add - Optional element. Adds a type reference to the collection.
  • clear - Optional element. Removes all references to inherited type names, allowing only the references that are added by the current add element.
  • remove - Optional element. Removes a reference to an inherited type name from the collection.
Parent Elements
  • configuration - Specifies the root element in every configuration file that is used by the common language runtime and the .NET Framework applications.
  • Telerik.Reporting - Configures all settings that Telerik Reporting Engine uses.

When providing the Public Key Token, the Reporting Engine will try to match it with the Public Key Token of the found DLL. It will not load an assembly with the same name and a different Public Key Token and will throw an exception instead. If the Public Key Token is omitted in the configuration, the Reporting Engine will load the first DLL, which name matches the provided Assembly Name. Potentially, this may allow bad agents to replace trusted assemblies with malicious ones and constitutes a security vulnerability. Since the Public Key Token provides an extra security layer to your application, we advise to always include it in the configuration file.

Example

The following code example demonstrates how to configure the Reporting Engine to use the MyNamespace.MyClassName type from the MyAssemblyName assembly, which has a public key token with the value my-assembly-public-key-token. If the type is correctly resolvable at runtime, it will be permitted to be used as a source for the ObjectDataSource's data retrieval. This configuration element also allows listing custom types that are allowed in the report definition.

XML-based configuration file:

<?xml version="1.0"?>
<configuration>
    <configSections>
        <section name="Telerik.Reporting" type="Telerik.Reporting.Configuration.ReportingConfigurationSection, Telerik.Reporting" allowLocation="true" allowDefinition="Everywhere" />
    </configSections>
    <Telerik.Reporting>
        <TypeReferences>
            <add typeName="MyNamespace.MyClassName" assemblyName="MyAssemblyName" publicKeyToken="my-assembly-public-key-token" />
        </TypeReferences>
    </Telerik.Reporting>
...
</configuration>

JSON-based configuration file:

"telerikReporting": {
    "TypeReferences": [
        {
            "typeName": "MyNamespace.MyClassName",
            "assemblyName": "MyAssemblyName",
            "publicKeyToken": "my-assembly-public-key-token"
        }
    ]
}

When adding the Telerik.Reporting section manually, do not forget to register it in configSections element of the configuration file. Failing to do so will result in a ConfigurationErrorsException with the following text: Configuration system failed to initialize.