Net 8 MultiDocument ADD mtehod Fails because of LinearGradientBrush

Posted by: hrvoje.zirdum on 6 December 2024, 11:52 am EST

    • Post Options:
    • Link

    Posted 6 December 2024, 11:52 am EST - Updated 6 December 2024, 12:01 pm EST

    Hi,

    I have a WinForms 4.8 desktop application. When I migrated it to Net 8, I’ got an error in MultiDocument.Add function when I create a PrintDocument object with RenderTextObject using LinearGradientBrush as a brush.

    I have changed a little example code from your pages (https://developer.mescius.com/componentone/docs/win/online-printdocument/multi-document.html) so you can reproduce the error on your side (marked it with “// added - Begin” and // added - End")

    C1PrintPreviewControl ppc = new C1PrintPreviewControl();
    Controls.Add(ppc);
    ppc.Dock = DockStyle.Fill;
    C1PrintDocument pdoc = new C1PrintDocument(); 
    C1PrintDocument pdoc2 = new C1PrintDocument(); 
    C1MultiDocument mdoc = new C1MultiDocument();
    pdoc.Body.Children.Add(new C1.C1Preview.RenderText("Hello!"));
    pdoc2.Body.Children.Add(new C1.C1Preview.RenderText("World!"));
    
    // added - Begin
     RenderText rTex = new RenderText();
     LinearGradientBrush brusBackground = new LinearGradientBrush(new Rectangle(0, 0, 1, 1), Color.White, Color.FromArgb(255, 255, 153), LinearGradientMode.Vertical);
     rTex.Style.Brush = brusBackground;
     rTex.Text = "Tekst with LinearGradientBrush";
     pdoc.Body.Children.Add(rTex);
    // added - End
         
    mdoc.Items.Add(pdoc);
    mdoc.Items.Add(pdoc2); 
    ppc.Document = mdoc;
    mdoc.Generate();

    When I run the code above in the .NET 8 WinForms project, I’m getting this error: “System.NullReferenceException: ‘Object reference not set to an instance of an object.’”.

    This is StackTrace:

    " at C1.C1Preview.GraphicsUtils.d(**LinearGradientBrush **a)\r\n at fp.fk(fa a, Object b, Boolean c)\r\n at fc.gg(Object a, ey b, Boolean c, Boolean d, Boolean e)\r\n at fc.gg(Object a, Boolean b, Boolean c)\r\n at fa.bq(Object a, Boolean b, Boolean c)\r\n at fa.au(Int32 a, Object b, Boolean c, Boolean d)\r\n at C1.C1Preview.Style.a.NS_Serialize(fa a)\r\n at C1.C1Preview.PropsHashtable`1.C1.C1Preview.NativeSerialization.IC1NativeSerializable.Serialize(fa a)\r\n at fc.gg(IC1NativeSerializable a, Boolean b, Boolean c)\r\n at fa.am(Int32 a, IC1NativeSerializable b, Boolean c, Boolean d)\r\n at C1.C1Preview.Style.NS_Serialize(fa a)\r\n "

    Can you help me?

    Regards,

    Hrvoje

  • Posted 9 December 2024, 6:27 am EST

    Hello Hrvoje,

    Thank you for sharing the details. We’re also able to observe the behavior on our end.

    We have escalated it to the development team for further investigation. Rest assured, we’ll get back to you once we have more information. [Internal tracking ID: C1WIN-33432]

    Regards,

    Uttkarsh.

  • Posted 13 May 2026, 6:53 am EST

    Hello Hrvoje,

    The issue has been resolved in the latest version of the controls. Please upgrade to the latest major version, v740 or later, to resolve the issue on your end.

    Please refer to a sample using v761: PrintDoc_Sample_Updated.zip

    Regards,

    Uttkarsh.

  • Posted 14 May 2026, 1:54 am EST - Updated 14 May 2026, 2:13 am EST

    Hello

    It works fine with version 740, but with version 761 it throws error:

    "

    System.Exception: ‘Exception occurred during document generation:

    Index was outside the bounds of the array.’

    Inner exception

    IndexOutOfRangeException: Index was outside the bounds of the array.

    This exception was originally thrown at this call stack:

    [External Code]

    "

    Image of error is attached.

  • Posted 14 May 2026, 5:57 am EST

    Hello,

    Apologies for the oversight.

    We have escalated the behavior to the development team for further insights. [Internal Tracking ID: C1WIN-35294]

    We’ll get back once we have more information.

    Regards,

    Uttkarsh.

  • Posted 3 June 2026, 6:01 am EST

    Hello,

    The issue has been fixed in the latest release of C1.Win.Printing—10.0.20261.779.

    Please upgrade the C1 NuGet Packages and let us know your observations.

    Regards,

    Uttkarsh.

  • Posted 5 June 2026, 8:06 am EST

    It is ok now. Thanks.

Need extra support?

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

Learn More

Forum Channels