0

I have created rdlc report in VS 2022 and tried to run it but I get exceptions at reportViewev1.LocalReport.Setparameters(). These are the exceptions

ReportProcessingException: The report definition is not valid. Details: The report definition has an invalid target namespace 'http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition' which cannot be upgraded.

and

DefinitionInvalidException: The definition of the report '' is invalid.

namespace WM_App.Views
{
    public partial class Window1 : Window
    {
        public List<string> Labels { get; set; }
        public string VendorItemNo_ { get; set; }
        public string CrossRefNo_ { get; set; }
        public string SelectedLabel { get; set; }

        private Microsoft.Reporting.WinForms.ReportViewer reportViewer1;

        public Window1()
        {
            InitializeComponent();

            Labels = new List<string>
            {
                "Akerman",
                "MetalX"
            };

            this.

            DataContext = this;
        }

        private void Print_Button_Click(object sender, RoutedEventArgs e)
        {
            this.reportViewer1 = new ReportViewer();

            reportViewer1.LocalReport.ReportEmbeddedResource = "WM_App.Reports.Akerman.rdlc";
            reportViewer1.Location = new System.Drawing.Point(0, 0);
            reportViewer1.Name = "reportViewer1";
            reportViewer1.Size = new System.Drawing.Size(667, 439);
            reportViewer1.TabIndex = 0;

            var tt = new ReportParameter("TranslateTable", "ForTest");
            var vgt = new ReportParameter("VehicleGroupTable", "FordTransit");
            var vin = new ReportParameter("VendorItemNo", VendorItemNo_);
            var umt = new ReportParameter("UnitOfMeasureTable", "Test");
            var crn = new ReportParameter("VendorItemNo", CrossRefNo_);

            reportViewer1.LocalReport.SetParameters(tt);
            reportViewer1.LocalReport.SetParameters(vgt);
            reportViewer1.LocalReport.SetParameters(vin);
            reportViewer1.LocalReport.SetParameters(umt);
            reportViewer1.LocalReport.SetParameters(crn);
            reportViewer1.RefreshReport();
Luca
  • 1,588
  • 2
  • 22
  • 26
  • rdlc reports are a nigthmare. I switched to print directly WPF windows using the class `Systems.Windows.Documents.DocumentPaginator`. This way you can use the same approach (Model-View-ViewModel) for both windows and reports. Here an [example](http://www.nullskull.com/a/1378/wpf-printing-and-print-preview.aspx) – Marco Beninca Jul 19 '22 at 14:10
  • @MarcoBeninca i can't switch to another solution it is project that was created maybe 4 or 5 years ago by my colleague and i was supposed to add another report to it, he has same code but it works just fine and i get these errors for some reason and could not find any solution thanks for your advice anyway – Coupe de Grace Jul 20 '22 at 07:13
  • I understand and I was in the same situation but the time spent on switching to the new techonology was largely gained in saved time for modifications and maintenance – Marco Beninca Jul 20 '22 at 07:24

1 Answers1

0

if someone has same problem it's solution is hard to find but easy, just open your rdlc report in notepad and change Report xmlns to this.

<Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition" "http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">

hope it helps.