Error pdf with images. The type initializer for 'ae7' threw an exception

Posted by: nmengesha on 12 March 2024, 11:50 pm EST

    • Post Options:
    • Link

    Posted 12 March 2024, 11:50 pm EST - Updated 12 March 2024, 11:51 pm EST

    Hello.

    I have Active reports 17 with license, upgraded to 17.2.2, I can create most pdf reports, but I am getting error trying to create pdf with images.

    System.TypeInitializationException: The type initializer for ‘ai5’ threw an exception. —>

    System.IO.FileLoadException: Could not load file or assembly ‘System.Memory, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51’ or

    one of its dependencies. The located assembly’s manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

    at ai5.a()

    at ai5…cctor()

    — End of inner exception stack trace —

    at ai5.b()

    at ae7…ctor(afd A_0)

    at ae7.a()

    at System.Lazy

    1.CreateValue()    at System.Lazy
    1.LazyInitValue()

    at System.Lazy
    1.get_Value()    at ae7..cctor()    --- End of inner exception stack trace ---    at ae7.w()    at GrapeCity.Documents.Imaging.GcBitmap.Load(Stream stream, Int32 frameIndex, Nullable
    1 imageRect)

    at GrapeCity.ActiveReports.Core.Document.Drawing.Gc.I.?.?(Stream ?)

    at GrapeCity.ActiveReports.Core.Document.Drawing.Gc.GcImageConverterService.Convert(MemoryStream imageStream, ImageFormat allowedFormats, Boolean fixRotation)

    at GrapeCity.ActiveReports.Controls.Image.TryConvertImage(MemoryStream stream, Image& image, IImageConverterService imageConverterService)

    at GrapeCity.ActiveReports.Controls.Image…ctor(MemoryStream stream, IImageConverterService imageConverterService)

    at GrapeCity.ActiveReports.SectionReportModel.Picture.set_ImageBytes(Byte value)

    Thanks

    NM

  • Posted 13 March 2024, 6:29 pm EST

    Hi Netsa,

    This issue usually occurs due to missing or incompatible ActiveReports references used in your project. When upgrading a project/package it is suggested to use the ‘Upgrade Tool’ instead of manually updating the packages as the latest version of each package may/may not be compatible with the version of ActiveReports used in your project.

    To fix this issue please open your project in VisualStudio and use the ‘Tools > Convert to ActiveReports XX’, this will remove and re-add all the ActiveReports references compatible with your version of ActiveReports.

    After this ‘Clean’ and ‘Rebuild’ your project and it should work as expected.

    However, if the issue persists please share a stripped-down sample that replicates the issue so we can test the issue on our end and further investigate the same.

    Thanks,

    Anand

  • Posted 19 March 2024, 2:48 am EST

    Hi Anand,

    I am using upgrade too still get the error. the test project is referencing System.Memory, Version=4.0.1.1

    ..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll But when i check the System.Memory, dll version it is 4.6.285..

    Sample simple code using section report AnnualSummary with image

    [code] private SectionReport report;

    private void CreateFormAnnualSummaryPdf()

    {

    report = new SectionReport();

    AnnualSummary schedule = new AnnualSummary();

    schedule.Run();

    this.AddPages(schedule.Document.Pages);

    this.ExportToPDF();

    }

    public void AddPages(GrapeCity.ActiveReports.Document.Section.PagesCollection Pages)

    {

    addPages(Pages);

    }

    private void addPages(GrapeCity.ActiveReports.Document.Section.PagesCollection Pages)

    {

    report.Document.Pages.InsertRange(report.Document.Pages.Count, Pages);

    }

    public void ExportToPDF()

    {

    exportToPDF();

    }

    private void exportToPDF()

    {

    //Method declarations

    GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport objPDFExport = new GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport();

    string path = @"C:\Temp\Pdf\test.pdf";
    objPDFExport.ExportBookmarks = false;
    objPDFExport.Export(report.Document, path);
    

    }

    [/code]

    error

    he type initializer for ‘ai5’ threw an exception. —> System.IO.FileLoadException:

    Could not load file or assembly ‘System.Memory, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51’

    or one of its dependencies. The located assembly’s manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

    at ai5.a()

    at ai5…cctor()

    — End of inner exception stack trace —

    at ai5.b()

    at ae7…ctor(afd[] A_0)

    at ae7.a()

    at System.Lazy

    1.CreateValue()    at System.Lazy
    1.LazyInitValue()

    at System.Lazy
    1.get_Value()    at ae7..cctor()    --- End of inner exception stack trace ---    at ae7.w()    at GrapeCity.Documents.Imaging.GcBitmap.Load(Stream stream, Int32 frameIndex, Nullable
    1 imageRect)

    at GrapeCity.ActiveReports.Core.Document.Drawing.Gc.I.?.?(Stream ?)

    at GrapeCity.ActiveReports.Core.Document.Drawing.Gc.GcImageConverterService.Convert(MemoryStream imageStream, ImageFormat[] allowedFormats, Boolean fixRotation)

    at GrapeCity.ActiveReports.Controls.Image.TryConvertImage(MemoryStream stream, Image& image, IImageConverterService imageConverterService)

    at GrapeCity.ActiveReports.Controls.Image…ctor(MemoryStream stream, IImageConverterService imageConverterService)

    at GrapeCity.ActiveReports.SectionReportModel.Picture.set_ImageBytes(Byte[] value)

  • Posted 19 March 2024, 8:07 pm EST

    Hi Netsa,

    It would be difficult to comment upon the exact cause of the issue without going through a replicating sample, could you please share a stripped-down runnable sample that replicates the issue so we can test the same on our end and further investigate the issue?

    Thanks,

    Anand

Need extra support?

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

Learn More

Forum Channels