Does anybody know how I can get around this error or what it means?
Error: Microsoft.Reporting.WinForms.LocalProcessingException
Inner exception: Microsoft.ReportingServices.ReportProcessing.ProcessingAbortedException
(I put the full error as a comment inside the catch block in code snippet below)
This is my first attempt to run local reports / report viewer inside VS 2010, but this render method is exploding every time, and google seems not to turn up much help.
Can you spot any obvious mistakes?
FYI stuff not shown is a very simple XSD with one datatable, which is populated in the code to be used as a dataset, and one rdlc file (the report), which has one table in it and uses a datasource with just the one dataset (the xsd).
Thanks.
class Program
{
private const string UID = "myLogin";
private const string PASSWORD = "myPassword";
private const string IP = "myServerIPaddress";
static void Main(string[] args)
{
Warning[] warnings;
string[] streamIds;
string mimeType = string.Empty;
string encoding = string.Empty;
string extension = string.Empty;
try
{
using (MySqlConnection con = GetMySqlConnetion("schools"))
{
using (MySqlCommand cmd = new MySqlCommand())
{
cmd.Connection = con;
cmd.CommandText = @"SELECT `venrollmentandmaxenrollment`.`classId`,
`venrollmentandmaxenrollment`.`NumberOfStudentsEnrolled`,
`venrollmentandmaxenrollment`.`NumberOfMaxEnrollments`
FROM `schools`.`venrollmentandmaxenrollment`;";
MySqlDataReader sessionReportReader = cmd.ExecuteReader();
DataSet1 dataSet1 = new DataSet1();
dataSet1.Load(sessionReportReader, System.Data.LoadOption.Upsert, dataSet1.Tables[0].TableName);
ReportViewer viewer = new ReportViewer();
viewer.ProcessingMode = ProcessingMode.Local;
viewer.LocalReport.ReportPath = "C:\\VS\\TestReports\\TestReports\\Report1.rdlc";
viewer.LocalReport.DataSources.Add(new ReportDataSource(dataSet1.Tables[0].TableName, dataSet1.Tables[0]));
byte[] bytes = viewer.LocalReport.Render("PDF", null, out mimeType, out encoding, out extension, out streamIds, out warnings);
//TODO: do something with bytes, and drag this code back to the main application, once we get this working!
}
}
}
catch (Exception ex)
{
/*
LocalReport.Render always takes us here with this exception:
*
Microsoft.Reporting.WinForms.LocalProcessingException occurred
Message=An error occurred during local report processing.
Source=Microsoft.ReportViewer.WinForms
StackTrace:
at Microsoft.Reporting.WinForms.LocalReport.InternalRender(String format, Boolean allowInternalRenderers, String deviceInfo, PageCountMode pageCountMode, CreateAndRegisterStream createStreamCallback, Warning[]& warnings)
InnerException: Microsoft.ReportingServices.ReportProcessing.ProcessingAbortedException
Message=An error has occurred during report processing.
Source=Microsoft.ReportViewer.Common
ExceptionLevelHelpLink=http://go.microsoft.com/fwlink/?LinkId=20476&EvtSrc=Microsoft.ReportingServices.Diagnostics.Utilities.ErrorStrings&EvtID=rsProcessingAborted&ProdName=Microsoft%20SQL%20Server%20Reporting%20Services&ProdVer=1.0
SkipTopLevelMessage=false
StackTrace:
at Microsoft.ReportingServices.OnDemandProcessing.OnDemandProcessingContext.AbortHelper.ThrowAbortException(String reportUniqueName)
at Microsoft.ReportingServices.OnDemandProcessing.OnDemandProcessingContext.CheckAndThrowIfAborted()
at Microsoft.ReportingServices.OnDemandProcessing.RetrievalManager.FetchData(Boolean mergeTran)
at Microsoft.ReportingServices.OnDemandProcessing.RetrievalManager.PrefetchData(ReportInstance reportInstance, ParameterInfoCollection parameters, Boolean mergeTran)
at Microsoft.ReportingServices.OnDemandProcessing.Merge.FetchData(ReportInstance reportInstance, Boolean mergeTransaction)
at Microsoft.ReportingServices.ReportProcessing.ReportProcessing.ProcessOdpReport(Report report, OnDemandMetadata odpMetadataFromSnapshot, ProcessingContext pc, Boolean snapshotProcessing, Boolean reprocessSnapshot, Boolean processUserSortFilterEvent, Boolean processWithCachedData, ErrorContext errorContext, DateTime executionTime, IChunkFactory cacheDataChunkFactory, StoreServerParameters storeServerParameters, GlobalIDOwnerCollection globalIDOwnerCollection, SortFilterEventInfoMap oldUserSortInformation, EventInformation newUserSortInformation, String oldUserSortEventSourceUniqueName, ExecutionLogContext executionLogContext, OnDemandProcessingContext& odpContext)
at Microsoft.ReportingServices.ReportProcessing.ReportProcessing.RenderReport(IRenderingExtension newRenderer, DateTime executionTimeStamp, ProcessingContext pc, RenderingContext rc, IChunkFactory cacheDataChunkFactory, IChunkFactory yukonCompiledDefinition, Boolean& dataCached)
at Microsoft.ReportingServices.ReportProcessing.ReportProcessing.RenderReport(IRenderingExtension newRenderer, DateTime executionTimeStamp, ProcessingContext pc, RenderingContext rc, IChunkFactory yukonCompiledDefinition)
at Microsoft.Reporting.LocalService.CreateSnapshotAndRender(CatalogItemContextBase itemContext, ReportProcessing repProc, IRenderingExtension renderer, ProcessingContext pc, RenderingContext rc, SubreportCallbackHandler subreportHandler, ParameterInfoCollection parameters, DatasourceCredentialsCollection credentials)
at Microsoft.Reporting.LocalService.Render(CatalogItemContextBase itemContext, Boolean allowInternalRenderers, ParameterInfoCollection reportParameters, IEnumerable dataSources, DatasourceCredentialsCollection credentials, CreateAndRegisterStream createStreamCallback, ReportRuntimeSetup runtimeSetup)
at Microsoft.Reporting.WinForms.LocalReport.InternalRender(String format, Boolean allowInternalRenderers, String deviceInfo, PageCountMode pageCountMode, CreateAndRegisterStream createStreamCallback, Warning[]& warnings)
InnerException: Microsoft.ReportingServices.ReportProcessing.ReportProcessingException
Message=DataSet1
Source=Microsoft.ReportViewer.Common
ExceptionLevelHelpLink=http://go.microsoft.com/fwlink/?LinkId=20476&EvtSrc=Microsoft.ReportingServices.Diagnostics.Utilities.ErrorStrings&EvtID=rsErrorCreatingDataReader&ProdName=Microsoft%20SQL%20Server%20Reporting%20Services&ProdVer=1.0
SkipTopLevelMessage=false
StackTrace:
at Microsoft.ReportingServices.OnDemandProcessing.RuntimeDataSet.RunDataSetQuery()
at Microsoft.ReportingServices.OnDemandProcessing.TablixProcessing.RuntimeOnDemandDataSet.Process()
at Microsoft.ReportingServices.OnDemandProcessing.RuntimeDataSet.ProcessConcurrent(Object threadSet)
InnerException:
*/
}
}
public static MySqlConnection GetMySqlConnetion(string DB)
{
string connStr = String.Format(
"SERVER={0}; Port={1}; UID={2}; PASSWORD={3}; DATABASE={4}; pooling={5};",
IP,
"3306",
UID,
PASSWORD,
DB,
"false");
MySqlConnection mycon = null;
try
{
mycon = new MySqlConnection(connStr);
mycon.Open();
}
catch (MySqlException ex)
{
Logger logger = new Logger("Test Reports App");
logger.Log(ex);
}
return mycon;
}
}
Create a custom class to bind your data to.
public class MyReportClass
{
public int ID {get;set;}
public string Name {get;set;}
}
Then populate the class using a DataReader
//snippet
MySqlDataReader reader = cmd.ExecuteReader();
// add to collection
List<MyReportClass> myReportClassCollection = new List<MyReportClass.();
while (reader.Read())
{
// populate entity
var myReportClass = new MyReportClass();
// set properties, skipping DBNull checking for quickness
myReportClass.ID = (int)reader["ID"];
myReportClass.Name = (string) reader["Name"];
myReportClassCollection.Add(myReportClass);
}
ReportViewer viewer = new ReportViewer();
viewer.ProcessingMode = ProcessingMode.Local;
viewer.LocalReport.ReportPath = "C:\\VS\\TestReports\\TestReports\\Report1.rdlc";
viewer.LocalReport.DataSources.Add(new ReportDataSource("myDataSource", myReportClassCollection));