Dynamically selecting an ObjectDataSource via the NeedDataSource function no longer works.

2 Answers 168 Views
.NET Framework DataSource Object DataSources Expressions Installation Upgrade
Bridge24
Top achievements
Rank 1
Iron
Iron
Bridge24 asked on 25 Apr 2022, 01:56 PM | edited on 25 Apr 2022, 02:05 PM

I would like to upgrade my version of Telerik Reporting from version 13 to 16, but the latest version that works well is 14.0.20.115, then I have some problems. I'm using the Designer for Visual Studio 2019 with the .Net Framework 4.

My report uses the NeedDataSource function to dynamically select the correct ObjectDataSource, but as of version 14.0.22.119 the Member function is never called.   No error is generated, it's just as if the dataSource was not defined. I also tried several other revisions (15.2 and 16.0) and got the same result. If I force a particular objectDataSource in the report, it works but I don't want to copy the same report 3 times just because I have 3 different objectDatasource.

This is what my NeedDataSource function looks like: 

private void MyReport_NeedDataSource(object sender, System.EventArgs e)
{
	CurrentReport = ((Telerik.Reporting.Processing.Report)sender);
	var paramProviderName = CurrentReport.Parameters.Where((param) => param.Key.ToLower() == "providername").Single().Value;

	switch (paramProviderName.Value.ToString())
	{
		case "provider1":
			DataSource = odsProvider1;
			break;
		case "provider2":
			DataSource = odsProvider2;
			break;
		case "provider3":
			DataSource = odsProvider3;
			break;
	}
}

As a second problem, my user functions no longer appear in the Edit Expression popup.

Is there a solution for these 2 problems?

2 Answers, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 28 Apr 2022, 08:23 AM

Hello Daniel,

The DataSource variable from the code snippet seems to be accessed from outside the NeedDataSource event, this is probably the data source of the report, is that correct?

In any case, in order to update the DataSource of a report or one of its report items, you should access the report.DataSource from the sender object of the MyReport_NeedDataSource method. For example:

DataSource = odsProvider1;

Should be:

CurrentReport.DataSource = odsProvider1;

This is due to changes that we have made on how events are accepted and applied to report and report items.  We have created a special article with guidance on how the events should be modified to work with the new versions - Changes on items in report events are not applied.

Regarding the user functions problem, that could be due to a mismatch with the version of Telerik Reporting used in the user functions class assembly and the report library project. Try to build the user functions assembly for the version of Telerik Reporting that you are currently using in the report library project.

Also, please keep in mind that the designer cannot recognize assemblies that target .NET Core/5/6 and higher or .NET Standard 2.1 and higher.

If everything is correct and the issue still persists, please try to use Fuslogvw.exe to check why the user function assembly is not binding. See the Assembly Used in ObjectDataSource is Not Loaded KB article for information on how to use the tool. It is also applicable to the VS Designer.

I hope the provided information will help.

Regards,
Dimitar
Progress Telerik

Brand new Telerik Reporting course in Virtual Classroom - the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products. Check it out at https://learn.telerik.com/.
0
Bridge24
Top achievements
Rank 1
Iron
Iron
answered on 02 May 2022, 05:58 PM | edited on 02 May 2022, 06:16 PM

Hi Dimitar,

Thank you for your detailed response, it is much appreciated.

For my first issue with version 14.0.20.119 (not 22, there was an error in my first post), fixing my datasource assignment as you suggested (CurrentReport.DataSource = odsProvider1) worked fine. Thank you!

After that, my second issue (users functions not visible in designer) didn't reappear in this release.

However, I am still not able to install the most recent version because my report crashes at version 15.2.21.1110 :

In VS 2019 I get an error in the designer (see image).

I also tried in VS 2022. The designer is not in error, but the user functions are gone again.  All references are correct and no problems were found with fuslogvw.exe.

The latest version that works well in VS 2019 is 15.2.21.915 (not compatible vs 2022).

 

Todor
Telerik team
commented on 05 May 2022, 02:23 PM

Hi Daniel,

Did you upgrade your ReportLibrary project with the Upgrade Wizard after installing the newer Reporting version? This is a must before using the Visual Studio designer of the newer version.

You may check also the troubleshoot approaches explained in the articles:

Bridge24
Top achievements
Rank 1
Iron
Iron
commented on 09 May 2022, 07:43 PM

Hi Todor,

I upgrade my ReportLibrary project with the Upgrade Wizard everytime I change the version.  It's only with the version 15.2.21.1110 I have a problem.

Dimitar
Telerik team
commented on 12 May 2022, 10:49 AM

Would you please consider upgrading to the latest version? We released it yesterday and the problem that you have may disappear with the newest version.

If it does not, please follow the troubleshooting Visual Studio Problems article to collect information about the problem that you can then send in this thread.

It would be even better if you could attach the problematic project.

 

Tags
.NET Framework DataSource Object DataSources Expressions Installation Upgrade
Asked by
Bridge24
Top achievements
Rank 1
Iron
Iron
Answers by
Dimitar
Telerik team
Bridge24
Top achievements
Rank 1
Iron
Iron
Share this question
or