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

4 posts, 0 answers
  1. Jon
    Jon avatar
    813 posts
    Member since:
    Oct 2008

    Posted 23 Jul 2012 Link to this post

    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
  2. Jon
    Jon avatar
    813 posts
    Member since:
    Oct 2008

    Posted 23 Jul 2012 Link to this post

    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)
  3. DevCraft banner
  4. Amritpal
    Amritpal avatar
    1 posts
    Member since:
    May 2016

    Posted 09 Jun Link to this post

    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();

  5. Stef
    Admin
    Stef avatar
    3036 posts

    Posted 09 Jun Link to this post

    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
Back to Top