Click here to Skip to main content
15,880,503 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
When I was rendering SSRS report in web API, exception was throwing as

An exception of type 'Microsoft.Reporting.WebForms.LocalProcessingException' occurred in Microsoft.ReportViewer.WebForms.dll but was not handled in user code

What I have tried:

LocalReport localReport = new LocalReport();
           localReport.ReportPath = System.Web.HttpContext.Current.Server.MapPath(this.LocalModel.FileName);

           this.LocalModel.ReportDataSets.ForEach( k=> {
                localReport.DataSources.Add(k);
           });

           localReport.EnableExternalImages = true;
           string reportType = this.LocalModel.Format.ToString();
           string encoding;
           string fileNameExtension;
           string deviceInfo =
           "<DeviceInfo>" +
           "  <OutputFormat>" + this.LocalModel.Format.ToString() + "</OutputFormat>" +
           "</DeviceInfo>";

           Warning[] warnings;
           string[] streams;
           byte[] renderedBytes;

       localReport.Refresh();
           renderedBytes = localReport.Render(
               reportType,
               deviceInfo,
               out mimeType,
               out encoding,
               out fileNameExtension,
               out streams,
               out warnings);

           this.LocalModel.LastmimeType = mimeType;
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900