Trouble binding ObjectDataSource to custom class in programmatically created report

1 Answer 13 Views
.NET Core DataSource Object General Discussions Localization Programming
Jim
Top achievements
Rank 1
Jim asked on 09 Sep 2025, 09:32 AM

Hello Telerik team,

I’m trying to create a simple Telerik report programmatically and bind data from a custom class using an ObjectDataSource. My class has a method GetCustomers() that returns a collection of items.

Simplified setup:

var report = new Telerik.Reporting.Report();

var objectDataSource = new Telerik.Reporting.ObjectDataSource();
objectDataSource.DataSource = typeof(CustomerDetailedModel);
objectDataSource.DataMember = "GetCustomers"; // returns IEnumerable<CustomerDetailedModel>

report.DataSource = objectDataSource;


I’ve also tried leaving DataMember

unset, but I still get an error related to assembly trust or type resolution, e.g.,

“The type or namespace ‘CustomerDetailedModel’ could not be found, or the assembly is not trusted.”

I’ve tried:

  • Adding the DLL via AssemblyRef.FromFile

  • Placing the DLL in the application output folder

  • Using AppDomain.CurrentDomain.AssemblyResolve

  • Configuring assembly references in appsettings.json

Despite this, the report cannot resolve the type at runtime.

Questions:

  1. How do I make ObjectDataSource resolve a CLR type from a custom assembly in a programmatically created report?

  2. What is the recommended way to configure assembly references in .NET Core / .NET 8 for reports?

Any guidance or examples would be greatly appreciated.

1 Answer, 1 is accepted

Sort by
0
Todor
Telerik team
answered on 12 Sep 2025, 06:58 AM

Hi Jim,

Let me start by suggesting to set the Report DataSource directly to the method/property that is going to return the data. Consider the following code:

var report = new Telerik.Reporting.Report();
report.DataSource = GetCustomers();// Replace with the exact method signature

The ObjectDataSource internally uses reflection to instantiate the type and invoke the method/property to fetch the data. This may be an overhead in your scenario. When creating or modifying the report with code, the above approach may be better and won't require registering the assembly in the Telerik Reporting configuration. The ObjectDataSource component is suitable for TRDX/TRDP reports that are XML report templates.

Regarding the registration of assemblies as trusted, currently, this may be done in the configuration file, or other IConfiguration implementation, through the following elements:

Since the configuration is read only when starting the application, the approach doesn't let register assemblies loaded at runtime.

With the upcoming Reporting version, we will let our users register the assemblies with code as trusted.

Let me also reply to your questions:

  • How do I make ObjectDataSource resolve a CLR type from a custom assembly in a programmatically created report?

Use the above configuration elements in the configuration file of the project hosting the Reporting Engine (ReportProcessor).

  • What is the recommended way to configure assembly references in .NET Core / .NET 8 for reports?

You may do this in the appsettings.json configuration file of the project hosting the Reporting Engine. The file will be read to resolve the configuration when the application starts.

Regards,
Todor
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
.NET Core DataSource Object General Discussions Localization Programming
Asked by
Jim
Top achievements
Rank 1
Answers by
Todor
Telerik team
Share this question
or