Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
65
igr report downloads on local version, not when hosted on IIS server
posted

I've been scratching my head at this for a few months now. I've written a company directory for my job and one feature was reporting capabilities of an org structure.

The program is written in asp.NET with .NET framework 4.5

I've created the .igr report and everything shows perfect when I run it locally or preview the igr report.

It works with two parameters that are chosen from dropdown boxes on the page and the report is generated once a submit button is clicked.

I only need the report to be downloaded directly after the button has been clicked, therefore my reason for not usign and report viewers.

Code below with error message pulled from server script. (Hopefully no typing errors, I have to go between classified and unclassified computers)

 

Private Sub toPDF(ByVal parameterList As IEnumerable(Of ParameterValue))

       Dim reportUri = New Uri(“/DirectoryASPForms;component/Emp.igr”, UriKind.Relative)

       Dim exporter = ServerExporterFactory.CreateExporter(reportUri)

       Using (exporter)

              Dim MemoryStream As New MemoryStream

              exporter.Parameters = parameterList

              exporter.Export(MemoryStream, “PDF”)

              SendStreamToResponse(MemoryStream, “EmployeeReport.pdf”, “application/pdf”)

              MemoryStream.Close()

       End Using

End Sub

Private Sub SendStreamToResponse(stream As MemoryStream, filename As String, reportType As String)

       Dim reportBuffer = stream.ToArray()

       Response.AddHeader(“Content-Length”, reportBuffer.Length.ToString())

       Response.ContentType = reportType

       Response.AddHeader(“Expires”, “0”)

       Response.AddHeader(“Cache-Control”, ”must-revalidate, post-check=0, pre-check=0”)

       Response.AddHeader(“Pragma”, “public”)

       Response.AddHeader(“Content-Disposition”, “attachment; filename =” + filename)

       Response.BinaryWrite(reportBuffer)

       Response.Flush()

       Response.End()

End Sub

 

Error:

Infragistics.Reports.Server.ReportProcessorException: An error occurred while processing the Report. ---> System.NullReferenceException: Object reference not set to an instance of an object.

at Infragistics.Reports.Engine.ServiceModelMefDiscoverer.Initialize(IServiceModelManager serviceModel)

at Infragistics.Reports.Server.ServerExporter.CreateLocalEngine(IEnumberable`1 dataSources, IReportInstanceSession& session)

at Infragistics.Reports.Server.ServerExporter.Export(Stream output, String exportFormat)

--- End of inner stack trace ---

at Infragistics.Reports.Server.ServerExporter.Export(Stream output, String exportFormat)

at DirectoryASPForms.ReportGen.toPDF(IEnumerable`1 parameterList)’);

 

  • 16310
    Offline posted

    Hi Robert,

    Thank you for posting in the Infragistics community !

    Please have a look at the following online sample:

    http://www.infragistics.com/samples/aspnet/infragistics-documents/export-to-pdf-or-xps that demonstrates the exaxt goal you follow - how to create a report and download it, without the need to preview it in the page. You can compare your code to the recommended approach used.

    If error still exists please provide some more details so that I can try to reproduce and investigate it on my side. Any working sample will be highly appreciated. Looking forward to hearing from you.

    • 65
      posted in reply to Hristo Anastasov

      Hristo,

      Thank you for your reply. I don't think that solution will work for my application. The report is built from a sql query from the parameters entered by the user. I'm not totally against using the xam reportViewer or even a HTML report viewer. I've tried the silverlight project but haven't been able to get it running either. Do you have any asp.NET solutions that I could view as an example that may closely resemble my own? My silverlight project 'DirectoryReport' using xamReportViewer is set up as follows.

      Silverlight 5

      The MainPage.xaml and App.xaml is in the DirectoryReport section

      The Report.igr, Report.svc, TestPage.html/aspx, and Web.Config are in the DirectoryReport.Web section

      My trouble with this way is I haven't figured out how to link the .igr report to the report viewer while they are in different sections. I will provide code below.

      <ig:XamReportViewer x:Name="igReportViewer" VerticalAlignment="Center" HorizontalAlignment="Center" Height="430" Width="646">

           <ig:XamReportViewer.RenderSettings>

                 <ig:ClientRenderSettings DefinitionUri="DirectoryReport.Web;component/EmpReport.igr" />

           </ig:XamReportViewer.RenderSettigns>

      </ig:XamReportViewer>

       

      I've tried many different combinations of the relative path and no luck yet. When I run the application I get the error "Cound not find report definition /DirectoryReport.Web;component/EmpReport.igr"

      My report build action is set to Content and Always copy to Output Directory

       

      • 16310
        Offline posted in reply to Robert Thompson

        Hello Robert,

        Sorry for my late response ! I am glad you have managed to resolve your issue. Meanwhile I have prepared an ASP.NET solution as per your request - there is a Report that id displayed on the Default page using the HTML 5 Report Viewer, and there is also another page that demonstrates how you can create and directly download a report using the Infragistics documents.

        Regarding the error you receive now - please have a look at this forum thread where such an issue is discussed - http://www.infragistics.com/community/forums/t/70941.aspx.

        I hope it is helpful to you. Please let me know if you have further questions.

        InfraReportingProject.zip
        • 65
          posted in reply to Hristo Anastasov

          Hristo,

          I've gotten the XamReportViewer to work locally on my computer using a sql query to populate a parameter value. The only issue I have now is an error while trying to run the project on the IIS server. I get the error Infragistics.Reports.Engine.EngineException: An error occurred while processing the report parameters.

          There isn't any additional information in the error details. (I will make a new thread for this issue)

          • 65
            posted in reply to Hristo Anastasov

            Hristo,

            Thank you for your help. Will you include code to demonstrate a parameter collection? Is it possible to bound the collection to a SQL query?

            • 16310
              Offline posted in reply to Robert Thompson

              Hi Robert,

              I am currently working to create a sample that will reseble your scenario and will update this thread when done. Thank you for your patience and understanding.