.Rdlc Report in MVC project - Managed Debugging Assistant 'PInvokeStackImbalance'
this has worked for me (keeping settings):
var deviceInfo = @"<DeviceInfo>
<EmbedFonts>None</EmbedFonts>
</DeviceInfo>";
byte[] bytes = rdlc.Render("PDF", deviceInfo);
I'm running Microsoft.ReportingServices.ReportViewerControl.WebForms 150.1400.0 with same problem.
Force iis express to run with 64 bit will solve this problem, steps:
- Tools
- Options
- Project and Solutions
- Web Projects and check the option
- Use the 64 bit version of IIS Express for web sites and projects
I bumped into this error when trying to export a RDLC to PDF while debugging only. Excel & Word gave no issues.
It appears to have started when we upgraded from ReportViewer.WinForms v14 to v15 some months back but we didn't notice because the error doesn't occur once the project is compiled, confirming what @marcusgambit mentioned about it being a "debugging exception".
I used @cyuz's suggestion in our WinForms project - in the project Compile tab I un-ticked the "Prefer 32-bit" and that fixed the issue.
@brosolomon's & @srivaishnavgandhe's suggestion about fonts appears correct too - Arial & Times New Roman render fine while the rest cause an error - I tested Calibri, Cambria, Verdana, Wingdings, Tahoma, Segoe.
The report contents and data appear to make no difference - it seems the presence of a tag in the RDLC with any font other than Arial or Times New Roman that appears to cause the issue.
If you are interested this MS article discusses the rendering of SSRS to PDF and how SSRS will attempt to embed a font in a PDF but only if very specific conditions are met...I'm surmising this is where the failure is occurring.
According to this answer, PInvokeStackImbalance is more of a "debugging assistant" than an exception. So...
In my case, as it did not prevent the report from being rendered, I just disabled this exception when debugging my project (see Tell the debugger to continue on user-unhandled exceptions). This did the trick for me.