Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.Rdlc Report in MVC project - Managed Debugging Assistant 'PInvokeStackImbalance'

I am so close to getting my last report up and running. I have not had this problem with any other reports. I am trying to create a report based off a database record. When I go to create the report by LocalReport and creating the parameters for the report I get the error message ‘Managed Debugging Assistant 'PInvokeStackImbalance' : 'A call to PInvoke function 'Microsoft.ReportViewer.Common!Microsoft.ReportingServices.Rendering.ImageRenderer.FontPackage::CreateFontPackage' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.' This is a .rdlc report for my MVC project. The record is correct and the values get inserted but when I go to display it /create it the report errors out. On the line ‘renderedBytes = localReport.Render(

/* TRACKER_TEST Database Connection ~ Debugging & Testing */
            TRACKER_TESTDataSet dataSet = new TRACKER_TESTDataSet();
            TRACKER_TESTDataSetTableAdapters.Service_Report_FieldsTableAdapter adapter = new TRACKER_TESTDataSetTableAdapters.Service_Report_FieldsTableAdapter();
            LocalReport localReport = new LocalReport();
            localReport.ReportPath = Server.MapPath("~/ReportForms/VirtualService2.rdlc");
            List<TRACKER_TESTDataSet.Service_Report_FieldsRow> report = new List<TRACKER_TESTDataSet.Service_Report_FieldsRow>();
            foreach(var row in list)
            {
                report.Add(adapter.GetDataBy(row.SN1, row.SN2).First());
            }
            ReportDataSource rds = new ReportDataSource("Service_Data", report);
            localReport.DataSources.Add(rds);


            // command specifies whether its a PDF EXCEL WORD IMAGE doc
            string reportType = command;
            string mimeType, encoding, fileNameExtension;

            string deviceInfo =
                "<DeviceInfo>" +
                "   <OutputFormat>" + command + "</OutputFormat>" +
                "   <PageWidth>8.5in</PageWidth>" +
                "   <PageHeight>11in</PageHeight>" +
                "   <MarginTop>0.5in</MarginTop>" +
                "   <MarginLeft>0.3in</MarginLeft>" +
                "   <MarginRight>0.3in</MarginRight>" +
                "   <MarginBottom>0.5</MarginBottom>" +
                "</DeviceInfo>";

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

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

            return File(renderedBytes, mimeType);
        }
like image 925
Bigbear Avatar asked Aug 06 '19 21:08

Bigbear


Video Answer


1 Answers

this has worked for me (keeping settings):

var deviceInfo = @"<DeviceInfo>
                    <EmbedFonts>None</EmbedFonts>
                   </DeviceInfo>";

byte[] bytes = rdlc.Render("PDF", deviceInfo);
like image 195
Francesco Moroni Avatar answered Sep 21 '22 02:09

Francesco Moroni