1
When adding a parameter to a ReportViewer
is happening from the version of schema
move to 2016, which brings me to the following error when trying to render the report
Message: Test method Syns.Web.Teste.Relatorios.Demonstrativoreporttest.Mytestmethodasync threw Exception: Microsoft.Reporting.Webforms.Localprocessingexception: An error occurred During local report Processing. ---> Microsoft.Reporting.Definitioninvalidexception: The Definition of the report 'D: Syns Syns Syns Syns Web Reports Demonstrativoreport.rdlc' is invalid. ---> Microsoft.ReportingServices.Reportprocessing.Reportprocessingexception: The report Definition is not Valid or supported by this version of Reporting Services. This could be the result of Publishing a report Definition of a later version of Reporting Services, or that the report Definition contains XML that is not well-Formed or the XML is not Valid based on the Report Definition schema. Details: The report Definition has an invalid target namespace 'http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition' which cannot be upgraded.
The code I use to render the report is basically the following
public async Task<ReportModel> Report(int demonstrativoId, string path)
{
var demonstrativo = await Demonstrativo(demonstrativoId);
var demonstrativos = new List<Demonstrativo>()
{
demonstrativo
};
var procedimentos = await DemonstrativoProcedimento(demonstrativoId);
LocalReport relat = new LocalReport
{
//caminho do arquivo rdlc
ReportPath = Path.Combine(path, "DemonstrativoReport.rdlc"),
EnableExternalImages = true,
};
//vinculando dataset ao objeto relat
relat.DataSources.Add(new ReportDataSource
{
Name = "DemonstrativoDataSet",
Value = demonstrativos
});
relat.DataSources.Add(new ReportDataSource()
{
Name = "DemonstrativoProcedimentoDataSet",
Value = procedimentos,
});
relat.SetParameters(new ReportParameter("NumeroDemonstrativoParam", demonstrativo.Numero.ToString()));
//definindo tipo que o relatório será renderizado
string reportType = "PDF";
//configurações da página ex: margin, top, left ...
string deviceInfo =
"<DeviceInfo>" +
"<OutputFormat>PDF</OutputFormat>" +
"<PageWidth>8.27in</PageWidth>" +
"<PageHeight>11.69in</PageHeight>" +
"<MarginTop>0.19685in</MarginTop>" +
"<MarginLeft>0.19685in</MarginLeft>" +
"<MarginRight>0.19685in</MarginRight>" +
"<MarginBottom>0.19685in</MarginBottom>" +
"</DeviceInfo>";
byte[] bytes;
//Renderizando o relatório o bytes
bytes = relat.Render(reportType, deviceInfo, out string mimeType, out string encoding, out string fileNameExtension, out string[] streams, out Warning[] warnings);
return new ReportModel(bytes, mimeType);
}
If I change the Reportviewer schema for 2008, remove some tags from the 2016 version, my code works, but whenever I re-edit the report, the version goes back to 2016.
I made an example and went up to github, the difference of the Reportviewer file can be seen in the commit https://github.com/pablotdv/WebApplication3/commit/ee48445507051a78afe59e18384c110ea3b230c7