This is a migrated thread and some comments may be shown as answers.

User-defined functions

4 Answers 287 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Raffaele
Top achievements
Rank 1
Raffaele asked on 21 Jun 2011, 09:47 AM
Can I use user-defined functions defined in an assembly different from the assembly where the report is located?

What about reports exported as XML? Can I call use user-defined functions in this kind of reports considering that they are not located in an assembly?

4 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 21 Jun 2011, 11:33 AM
Hello Raffaele,

In order the user function to work properly you have to deserialize the report from xml by using the report type that contains the user function. For example:

   var serializer = new XmlSerializer(typeof(ReportCatalog));
   var rc = (ReportCatalog)serializer.Deserialize(textReader);

Hope this helps.

Regards,
Steve
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Sergey
Top achievements
Rank 1
answered on 18 Nov 2011, 05:53 AM

Hello Steve,
Can you share small sample with report deserialization?
I try follow:

namespace Test
{
 public static class Helper1
 {
  public static string Test()
  { return ""; }
 }
}

Report contains "=Test.Helper1.Test()" value (http://www.telerik.com/help/reporting/expressions-user-functions.html).
When I try to start it I see error "The expression contains object Test that is not defined in current context".

0
Steve
Telerik team
answered on 23 Nov 2011, 10:40 AM
Hi Sergey,

I've attached the ProductCatalog demo report that is serialized to xml using the report type and is after that deserialized using the same report type instead of the base Telerik.Reporting.Report. The report has an user function ColorFromName that as you see works as expected when using this approach.
Note that I have commented out the InitializeComponent method in the report constructor, as otherwise the same items would be loaded twice.

Greetings,
Steve
the Telerik team

Q3’11 of Telerik Reporting is available for download. Register for the What's New in Data Tools webinar to see what's new and get a chance to WIN A FREE LICENSE!

0
Sergey
Top achievements
Rank 1
answered on 23 Nov 2011, 11:16 AM
Thank you!
Tags
General Discussions
Asked by
Raffaele
Top achievements
Rank 1
Answers by
Steve
Telerik team
Sergey
Top achievements
Rank 1
Share this question
or