Last Updated: 27 Mar 2023 06:39 by ADMIN
Release R1 2023 SP1
Created on: 15 Dec 2022 09:24
Category: GridView
Type: Bug Report
RadGridView: ExportToPDF throws MethodAccessException when the referenced DLLs target .Net Framework 4.8

An exception occurs when trying to export the RadGridView using the ExportToPDF class with the following message.

System.SystemException: 'System.MethodAccessException: Attempt by security transparent method 'Telerik.Pdf.Gdi.GdiFontEnumerator.get_FamilyNames()' to call native code through method 'Telerik.WinControls.NativeMethods.EnumFontFamiliesEx(IntPtr, LOGFONT, FontEnumDelegate, Int32, Int32)' failed.  Methods must be security critical or security safe-critical to call native code.
   at Telerik.Pdf.Gdi.GdiFontEnumerator.get_FamilyNames()
   at Telerik.Apoc.Pdf.FontSetup.AddSystemFonts(FontType fontType)
   at Telerik.Apoc.Render.Pdf.PdfRenderer.SetupFontInfo(FontInfo fontInfo)
   at Telerik.Apoc.Fo.FOTreeBuilder.Parse(XmlReader reader)'

This exception is observed only when the referenced DLLs target the .Net Framework 4.8 version.

1 comment
Dinko | Tech Support Engineer
Posted on: 15 Dec 2022 09:30

Hi Derek,

Thank you for reporting this.

I was able to reproduce this exception and I can confirm that it is reproducible only when the DLLs target 4.8 .Net. As a workaround, you can consider using the GridViewPdfExport which is a better option for exporting the grid content as it utilizes the powerful RadPdfProcessing library and exports the data natively to the PDF format.

Dinko | Tech Support Engineer
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at