RichTextBox Error

Posted by: alexander.kainz on 6 February 2023, 11:09 pm EST

    • Post Options:
    • Link

    Posted 6 February 2023, 11:09 pm EST

    If we fill the RichTextBox with the attached HTML, we got an error.

    We use AR 16.3.2

    I think, the cause of the problem is: “border-top:solid”

    Error:

    System.NullReferenceException: Object reference not set to an instance of an object.

    at GrapeCity.ActiveReports.Document.Section.Adapter.RdfCanvasAdapter.GrapeCity.ActiveReports.Drawing.IDrawingCanvas.FillRectangle(BrushEx brush, RectangleF rect)

    at GrapeCity.ActiveReports.Document.Section.Adapter.RdfCanvasAdapter.GrapeCity.ActiveReports.Drawing.IDrawingCanvas.FillPolygon(BrushEx brush, PointF polygon)

    at GrapeCity.ActiveReports.Core.Rendering.I..DrawBorder( boxInfo, PointF start, PointF end, IDrawingCanvas canvas, BoxSide boxSide)

    at GrapeCity.ActiveReports.Core.Rendering.I..(RectangleF ,  , IDrawingCanvas )

    at GrapeCity.ActiveReports.Core.Rendering.I..ProcessDrawBorders()

    at GrapeCity.ActiveReports.Core.Rendering.I..Draw(GraphicsRenderContext context,  content)

    at GrapeCity.ActiveReports.Core.Rendering.I..Draw(GraphicsRenderContext context,  content)

    at GrapeCity.ActiveReports.Core.Rendering.I..Draw(GraphicsRenderContext context,  content)

    at GrapeCity.ActiveReports.SectionReportModel.RichTextBox.GrapeCity.ActiveReports.Controls.IControlInternal.Render(DrawCanvas page, PointF pageOffset, Single startPos, Single endPos)

    at GrapeCity.ActiveReports.SectionReportModel.ARControl.Render(Page page, PointF pageOffset, Single startPos, Single endPos, DeviceInfo info, ITextLayoutService textLayout, IImagePersistenceService imageService)

    at GrapeCity.ActiveReports.SectionReportModel.Section.Render(Page page,  drawingLog, PointF pageOffset, Single pageWidth, Single drawStartPos, Single drawEndPos)

    at GrapeCity.ActiveReports.Internal..ReLayout()

    at GrapeCity.ActiveReports.Internal..AddSection(Section section, Int32 insPos)

    at GrapeCity.ActiveReports.Internal..ProcessSectionPhase3(Section section, Boolean& groupFootersDone, Boolean& readyForFinalChecks)

    at GrapeCity.ActiveReports.Internal..ProcessPhase3(Boolean& groupFootersDone, Boolean& readyForFinalChecks)

    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)

    test.zip

  • Posted 7 February 2023, 8:10 pm EST

    Hi Alexander,

    We were able to notice this issue on our end, it seems like this issue gets caused when setting the border to ‘none’, ‘hidden’, or not specifying any value to the ‘border’ property. However, it works fine when we specify any other value to the border [solid, double, dotted, etc.].

    We have escalated this issue to our development team [Ticket ID: AR-30221] and will get back to you about any updates on the same.

    Regards,

    Anand

  • Posted 8 February 2023, 12:06 am EST

    Hi Anand,

    thank’s for your reply.

    Best regards,

    Alexander

  • Posted 8 February 2023, 3:14 pm EST

    Hi Alexander,

    The issue has been acknowledged by our development team and is expected to be fixed in ActiveReports v16.4 & ActiveReports v17.1.

    Regards,

    Anand

  • Posted 15 February 2023, 11:17 pm EST

    Hi,

    This issue has been fixed in ActiveReports v17.0.1. You may download the same from here: http://cdn.grapecity.com/ActiveReports/ar17/ActiveReports-v17.0.1.exe.

    Regards,

    Anand

  • Posted 24 February 2023, 7:32 am EST

    There still seems to be an issue with the RichTextBox control. When adding it to a section report in AR v17.0.1 (.net 4.8 app in VS2019), the designer fails when saving the report with a message "Code generation for property ‘RTF’ failed. Error was: 'Property accessor ‘RTF’ on object ‘richTextBox2’ threw the following exception: 'Object reference not set to an instance of an object.

    Similarly, running existing reports with rich text boxes fails with an error “Object reference not set to an instance of an object.​ At GrapeCity.​ActiveReports.​SectionReportModel.​RichTextBox.​set_RTF(String value)”

  • Posted 26 February 2023, 10:14 pm EST

    Hi Charles,

    We tried to replicate the issue on our system using ActiveReports 17.0.1, .NET Framework 4.8, and VS2019. However, adding a RichTextBox to our SectionReport did not throw any exceptions. We have attached our sample for the same.

    If the issue persists in our attached sample as well, please try reinstalling ActiveReports 17.0.1 from the following link: https://cdn.grapecity.com/ActiveReports/ar17/ActiveReports-v17.0.1_light.exe.

    Please Note: If you have ActiveReports 13 installed on your system please consider uninstalling the same or using ActiveReports 17 on VisualStudio 2022, as it has been observed that ActiveReports 13 interferes with the SectionReport designer of other versions of ActiveReports.

    Even after this if the issue persists, in order to investigate the issue further could you please share a stripped-down sample of your project or modify our attached sample such that it replicates the issue so we could further investigate the same?

    Regards,

    Anand

    RichTextBox_NET48_VS19.zip

  • Posted 27 February 2023, 10:25 am EST

    Thanks for the reply and sample project. I had older versions (v11 and v13) of AR installed, so I uninstalled them and reinstalled AR17. The designer now works for adding rich text boxes, but I continue to see exceptions thrown trying to access the RichTextBox.RTF property (get or set) at runtime (both in the InitializeComponent method and in detail_format). It doesn’t happen in your sample project, even when I copied one of the failing reports from my other VS solution to the sample project. I’ve scoured my computer for old AR dlls and removed any found. Can you think of why this problem would occur in one solution but not another on the same computer? My VS solution has three different class libraries (2 vb, 1 c#) using AR17 and all three have the same problem.

  • Posted 27 February 2023, 3:15 pm EST

    Hi Charles,

    Though there have been changes in the RichTextBox rendering, such as the RichTextBox only displays content as HTML in CrossPlatform CompatibilityMode and displays both RTF and HTML in GDI CompatabilityMode, you may try changing the CompatabilityMode to GDI and try rerunning your report.

    You may learn more about the same here: [ActiveReports 17 - RichTextBox] https://www.grapecity.com/activereportsnet/docs/latest/online/richtextbox.html#:~:text=The%20RichTextBox%20control%20supports%20loading%20an%20RTF%20file%20at%20design%20time%20with%20both CrossPlatform and GDI compatibility%20modes%20of%20a%20report.%20However%2C%20the%20RichTextBox%20control%20does%20not%20support%20the%20RTF%20file%20at%20run-time%20when%20the%20report's CompatibilityMode is%20set%20to CrossPlatform.

    However, as you have mentioned the issue is not replicated in our sample, it is most likely that you are accessing the RTF property of your RichTextBox before the RichTextBox is initialized. Because of this, it throws the “NullReferenceException”.

    Although, if this is not the reason for the issue, it would be difficult to comment upon the cause of the issue without actually going through a sample replicating the issue. Please share a stripped-down sample for the same so we could further investigate the issue.

    Regards,

    Anand

  • Posted 28 February 2023, 6:41 am EST

    I was able to finally reproduce the issue in a sample project (attached). The reports were already running in GDI mode, and the richtextbox.RTF null-reference was for the RTF property (get/set methods) and not the control itself, so initialization wasn’t the issue.

    It turns out to be some sort of AR dependency issue. The attached example is similar to the recently upgraded project I’m having problems with. It has an MVC web project with no AR dependencies that references a class library containing an AR section report and a helper class that generates a byte array using PdfExport. We don’t use the AR web viewer and so avoid needing any AR dependencies in the web tier of the projects we build. Instead, all reporting we do is passed to the web project as byte arrays for streaming to the browser.

    Try the attached example by building and running the web project and clicking the “Run Report” link on the Home/Index page. It should fail in the SectionReport1 detail_format method with the following error:

    [NullReferenceException: Object reference not set to an instance of an object.]

    GrapeCity.ActiveReports.SectionReportModel.RichTextBox.set_RTF(String value)

    (Also, if you hover over the richTextBox instance in detail_format while debugging you’ll see that the attempt by VS to show you the RTF value appears as “‘richTextBox1.RTF’ threw an exception of type ‘System.NullReferenceException’ at GrapeCity.ActiveReports.SectionReportModel.RichTextBox.get_RTF()” in the properties window.)

    Then, add a section report to the web project to load in the AR dependencies, after which the report will stop failing.

    There are several more AR-related dlls in the web project bin folder after a section report is added than when the dlls are being pulled in by reference to the reports class library during compilation. One or more of them must make a difference in supporting the RTF property.

    AR17_RichTextBox.zip

  • Posted 1 March 2023, 8:45 pm EST

    Hi Charles,

    We could notice in your sample that you have created a Reports Class Library Project and have referenced the same in your WebApplication1. In this case, you’ll have to license your class library using a ‘.gclicx’ file.

    Please refer to the following documentation to do the same Licensing Compiled Code: https://www.grapecity.com/activereportsnet/docs/latest/online/licensing-compiled-code.html

    Otherwise, if you are running your WebApplication1 on a licensed machine you may just add a ‘licenses.licx’ file to your WebApplication1 and it should work as expected.

    To do the same:

    • Right-click on your project in the Solution Explorer.
    • ‘Add > New item’ and add a new ‘SectionReport (XML-Based)’ adding this will also create a ‘licenses.licx’ file with all the required license strings and embed the same to your project, you may delete the newly added SectionReport after this.
    • Rebuild your WebApplication1.
    • Now running your WebApplication1 should work as expected.

    Please find attached the updated sample for the same.

    Regards,

    Anand

    AR17_RichTextBox.zip

  • Posted 2 March 2023, 12:13 am EST - Updated 2 March 2023, 12:25 am EST

    The web application is on the same licensed machine as the reports project (dlls of all projects in the VS solution are bundled together as a single web application). I added a licx file to the web project and it did not fix the problem. Your sample is only working because you’ve added all of the AR dependencies to the web project by adding a section report. Having to do this is not in line with good SoC practices (e.g., https://effectivesoftwaredesign.com/2012/02/05/separation-of-concerns/). Instead, there should be no need for AR references in the web project if the AR viewer is not being used.

    Check the differences in AR-related dlls in the web project bin folder when the web project has AR dependencies versus when it does not and only the Reports project has AR dependences. Several dlls appear in the web bin when AR dependencies are added that don’t exist otherwise:

    EnvDTE.dll

    GrapeCity.ActiveReports.Chart.Win.dll

    GrapeCity.ActiveReports.Core.Drawing.Gdi.dll

    GrapeCity.ActiveReports.Core.Export.Image.Page.dll

    GrapeCity.ActiveReports.Core.Export.Tiff.Section.dll

    GrapeCity.ActiveReports.Design.Win.dll

    GrapeCity.ActiveReports.Export.Image.dll

    GrapeCity.ActiveReports.Export.Image.Win.dll

    GrapeCity.ActiveReports.Serializer.dll

    GrapeCity.ActiveReports.Viewer.Common.dll

    GrapeCity.ActiveReports.Viewer.Win.dll

    GrapeCity.ActiveReports.Win.dll

    GrapeCity.Documents.DX.Windows.dll

    GrapeCity.Documents.Imaging.Windows.dll

    Microsoft.Bcl.AsyncInterfaces.xml (dll already present, but different version(?))

    stdole.dll

    System.Runtime.CompilerServices.Unsafe.xml (dll already present, but different version(?))

    There may be others - I just did a quick comparison. I suspected that having one of these missing dlls would solve the issue and so copied the GrapeCity.ActiveReports.Win.dll file into the web bin folder. Having that dll alone resulted in the RTF property working properly. Why doesn’t that dll get copied into the web project bin like the other AR dlls? They’re all marked as ‘copy local’

  • Posted 5 March 2023, 2:08 pm EST

    Hi Charles,

    The ActiveReports DLL does not get automatically added to your web application as you haven’t used/referenced any ActiveReports component in your Web Application directly. Adding a report, etc. that directly references ActiveReports adds the ActiveReports DLLs to your project.

    However, when creating a class library that references ActiveReports, the library needs to be licensed using the ‘.gclicx’ file to be used in other projects without facing any license issues (without having to add ActiveReports references).

    However, we were able to notice using the ‘.gclicx’ file in your project does prevent the license error but still throws the ‘NullReferenceException’ for the RTF property. Hence, we have escalated this issue to our development team [Ticket ID: AR-30375] and will let you know of any updates we get from them.

    Regards,

    Anand

  • Posted 8 March 2023, 8:50 am EST

    Thanks for referring this to the dev team. To clarify, though:

    No AR references should be needed in the Web project for AR-related dlls to be copied from another project in the solution. Most AR dlls do in fact get copied into the Web bin folder when the solution is built, but some are missing per my March 2, 2023 post. Another solution I upgraded from AR14 to AR17 today was failing on a missing-dependency error when running PDF exports because GrapeCity.ActiveReports.Core.Drawing.Gdi.dll (on the 3/2/23 missing-dlls list) was missing from the Web project bin despite being referenced in the Reports project and present in the bin for that project. For some reason, VS seems to omit the list of dlls I provided earlier.

    My understanding is that gclicx files are for .NET core. My solutions are .NET framework. Either way, adding gclicx or licx files to the Web project has no effect.

  • Posted 8 March 2023, 3:11 pm EST

    Hi Charles,

    >> No AR references should be needed in the Web project for AR-related dlls to be copied from another project in the solution.

    You’re correct, however, when we added a report to your web project it also installed a few ActiveReports packages and added them to the list in the ‘packages.config’ file, due to which building your project reinstalls these packages.

    Please note, the ‘Object reference…’ error has been acknowledged by the developers as a bug as this issue has not been replicated till ActiveReports 16. For the time being in order to build your project you’ll need to have the DLLs in your web application as a workaround.

    Rest assured once this issue gets fixed you can license your ‘Reports’ project using the ‘.gclicx’ file without facing any error messages as ‘.gclicx’ file is used to license class library projects regardless of whether you are using .NET Core or Framework.

    So for the time being as a workaround, we suggest you add a report item along with the DLLs it ships within your web application in order to reference your class library without facing any error message.

    Regards,

    Anand

  • Posted 25 April 2023, 7:55 pm EST

    Hi Charles,

    This issue has been fixed by our development team in the latest version of ActiveReports you may download the same from here: https://www.grapecity.com/activereportsnet/download.

    Regards,

    Anand

Need extra support?

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

Learn More

Forum Channels