Net 8 MultiDocument ADD mtehod Fails because of LinearGradientBrush

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

  • 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.

Need extra support?

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

Learn More

Forum Channels