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

Unable to cast object to type 'Telerik.Reporting.ReportSource'.

3 Answers 1108 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Jon
Top achievements
Rank 1
Jon asked on 23 Jul 2012, 09:54 AM
Hi,

After the upgrade to the latest version I am now getting the following error:

Unable to cast object of type 'TimeAndAttendance.TimeAndAttendanceReport' to type 'Telerik.Reporting.ReportSource'.

This happens when I do the following.  This is bastardised code from the system but enough to generate the error.  

I am assuming and hoping that it's something simple to fix...

Regards,

Jon

    Dim report As TimeAndAttendance.TimeAndAttendanceReport = New TimeAndAttendance.TimeAndAttendanceReport()
    GenerateAndSendReportByRequest(report)
 
 
 
Public Shared Sub GenerateAndSendReportByRequest(ByVal report As Telerik.Reporting.IReportDocument)
    Dim reportProcessor As New Telerik.Reporting.Processing.ReportProcessor()
    Dim deviceInfo As Hashtable = New Hashtable()
    deviceInfo("FontEmbedding") = "Subset"
    Try
        Dim result As Telerik.Reporting.Processing.RenderingResult = reportProcessor.RenderReport("PDF", report, deviceInfo)
    Catch ex As Exception
 
    End Try
 
End Sub

3 Answers, 1 is accepted

Sort by
0
Jon
Top achievements
Rank 1
answered on 23 Jul 2012, 10:20 AM
Just figured - this didn't appear in the breaking change list - maybe was in the release earlier this year.  If anyone has a similar issue use the InstanceReportSource as below...

Cheers,

Jon

Dim instanceReportSource As New Telerik.Reporting.InstanceReportSource()
instanceReportSource.ReportDocument = report
 result As Telerik.Reporting.Processing.RenderingResult = reportProcessor.RenderReport("PDF", instanceReportSource, deviceInfo)
0
Amritpal
Top achievements
Rank 1
answered on 09 Jun 2016, 02:21 PM

Hi

I am using  telerik report viewer version"Version=10.1.16.504" when i am bind report to reportviewer
then show error 
'Error loading the report viewer's templates. (Template = /api/reports/resources/templates/telerikReportViewerTemplate-html)'


var report = new ReportingClassLibrary.JobReportDetail();
        var instanceReportSource = new Telerik.Reporting.InstanceReportSource();
        instanceReportSource.ReportDocument = report;
        this.ReportViewer.ReportSource = instanceReportSource;
        //instead of this: ReportViewer1.ReportSource.Parameters.Add("VoldId", 6841808);
        //add this:
          report.ReportParameters["jobId"].Value = ....;
          ReportViewer.RefreshReport();

0
Stef
Telerik team
answered on 09 Jun 2016, 05:04 PM
Hi Amritpal,

The error message indicates the the project uses an HTML5 Viewer or its wrapper, but the viewer cannot connect to the Reporting REST service. Most probably relative paths need adjustment.

In addition, the HTML5 Viewer is a client-side widget which sends short string messages to the server. It is the Reporting REST service that creates objects on the server and serves rendered content to the client. For more details, please check this KB article.

Regards,
Stef
Telerik
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 Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
Jon
Top achievements
Rank 1
Answers by
Jon
Top achievements
Rank 1
Amritpal
Top achievements
Rank 1
Stef
Telerik team
Share this question
or