Null Reference when trying to generate a section report from AWS Lambda

Posted by: gene on 31 March 2025, 2:13 pm EST

    • Post Options:
    • Link

    Posted 31 March 2025, 2:13 pm EST

    Hello,

    I have been trying to host my .net 8 project on AWS lambda to generate section reports using Active Reports 17.2.2. It works fine locally, but whenever I run my Lambda function from the AWS console and it hits the SectionReport.Run() function it errors out with this:

    Exception occurred while generating the report AUDITLOGReport: System.NullReferenceException: Object reference not set to an instance of an object.
       at GrapeCity.ActiveReports.Drawing.Core.FontsFactory.BuildFontCollection(FontInfo fontInfo)
       at GrapeCity.ActiveReports.Rendering.Tools.FuncExtensions.<>c__DisplayClass1_0`2.<Memoize>b__0(T x)
       at GrapeCity.ActiveReports.FontResolver.CustomDocumentFontsFactory.GrapeCity.ActiveReports.Core.Document.Drawing.Gc.IDocumentFontsFactory.GetFonts(Font font)
       at GrapeCity.ActiveReports.Core.Document.Drawing.Gc.GcTextLayoutService.CreateTextFormat(Font font, Color color, Single dpiX, IDocumentFontsFactory fontCache, LineBreakingAlgorithm lineBreaking, TextLayoutParams param, Boolean fontStyleEmulation, Boolean withEudc)
       at GrapeCity.ActiveReports.Core.Document.Drawing.Gc.GcTextLayoutService.Layout(String text, Font font, Single width, TextLayoutParams param)
       at GrapeCity.ActiveReports.SectionReportModel.TextBox.GrapeCity.ActiveReports.Controls.IControlInternal.FlexSize(SizeF& size)
       at GrapeCity.ActiveReports.Internal..ProcessFlexSize(Int32 sectionIndex)
       at GrapeCity.ActiveReports.Internal..FormatSection(Section section)
       at GrapeCity.ActiveReports.Internal..ProcessPageTillFull()
       at GrapeCity.ActiveReports.Internal..GrapeCity.ActiveReports.Layout.IExecReport.RenderPage(Page newPage, Single left, Single top, Single right, Single bottom, ExecMode flags, ExecStatus& status)
       at GrapeCity.ActiveReports.SectionReport.ProcessPage()
       at GrapeCity.ActiveReports.SectionReport.RunImpl(Boolean syncDocument)

    I had figured it couldn’t access any system-level fonts and thus was erroring, so I attempted to create my own IFontResolver implementation and added open source .ttf font files to my .net project as content to return from the GetFonts method. Unfortunatley, utilizing the custom FontResolver yields the same result. I am out of ideas and would appreciate any help. Thanks!

  • Posted 2 April 2025, 2:13 pm EST

    Hi Gene,

    You are on the right track. As per my understanding, this issue will be resolved once the Font Resolver is set up correctly.

    Please refer to the following pages of our documentation and check out the Directory Font Resolver: Example 2

    Also Note: Other than special folders you can also use application paths like

    <root>Fonts/*
    to get fonts.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels