Bug Report T300831
Visible to All Users

NullReferenceException when previewing a report instance that has Watermark.Text set to Null

created 9 years ago

Hi,

While working in with XtraReport designer, I suddenly noticed that I couldn't show the preview anymore. When clicking on the preview button, I got a popup with the message from NullReferenceException. See the output :

C#
A first chance exception of type 'System.InvalidCastException' occurred in ReportFactory.dll A first chance exception of type 'System.InvalidCastException' occurred in ReportFactory.dll 'TrianonHRReport.Win.vshost.exe' (Managed (v4.0.30319)): Loaded 'n5jj2x4i' 15.10.15 11:15:55.131 ================================================================================ The error occurred: Type: NullReferenceException Message: La référence d'objet n'est pas définie à une instance d'un objet. Data: 0 entries Stack trace: à DevExpress.XtraPrinting.Drawing.PageWatermark.DrawTextWatermark(IGraphics gr, RectangleF rect) à DevExpress.XtraPrinting.Drawing.PageWatermark.Draw(IGraphics gr, RectangleF rect, Int32 pageIndex, Int32 pageCount) à DevExpress.XtraPrinting.Drawing.Watermark.Draw(IGraphics gr, RectangleF rect, Int32 pageIndex, Int32 pageCount) à DevExpress.XtraPrinting.BrickExporters.PageExporter.DrawWatermark(IGraphics gr, RectangleF rect) à DevExpress.XtraPrinting.BrickExporters.PageExporter.DrawPage(IGraphics gr, PointF location) à DevExpress.XtraPrinting.Page.DevExpress.DocumentView.IPage.Draw(Graphics gr, PointF position) à DevExpress.XtraPrinting.Control.PrintControl.DrawPage(IPage page, Graphics graph, PointF position) à DevExpress.DocumentView.Controls.DocumentViewerBase.DrawPages(PaintEventArgs e) à DevExpress.DocumentView.Controls.DocumentViewerBase.view_Paint(Object sender, PaintEventArgs e) à System.Windows.Forms.PaintEventHandler.Invoke(Object sender, PaintEventArgs e) à System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer) à System.Windows.Forms.Control.WmPaint(Message& m) à System.Windows.Forms.Control.WndProc(Message& m) à DevExpress.DocumentView.Controls.ViewControl.WndProc(Message& m) à DevExpress.XtraPrinting.Preview.Native.WindowTargetBase.OnMessage(Message& m) à System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) InnerException is null

The exception comes from XtraPrinting assembly. The result was a big red cross instead of the preview of my report.

Since the last line was about Watermark, I looked into the XtraReport properties to see if there's something wrong there. Watermark was in bold like if some modification has been done, but I could see no modification at all.

Then I openend the repx file in a texteditor and found only one line about watermark :

C#
this.Watermark.Text = null;

I deleted this line and problem was solved, hurray !

I have no idea why such a "mistake" appeared in my repx. Regardless, I lost a lot some time and I think that the Assembly from DevExpress should handle this case in a better way. Can you please consider adding a more comprehensive message like "Watermark instance is missing" ? Or ignore properties definition when object is not instanciated ?

Thanks in advance for your response,

Best regards
Greg

Comments (1)
DevExpress Support Team 9 years ago

    Hi Greg,

    I have forwarded this issue to our developers for further research. You will receive an automatic message once the status of this ticket is changed.

    Answers approved by DevExpress Support

    created 9 years ago (modified 9 years ago)

    We have fixed the issue described in this ticket and will include the fix in our next maintenance update. To apply this solution before the official update, request a hotfix by clicking the corresponding link for product versions you require.

    Note: Hotfixes may be unavailable for beta versions and updates that are about to be released.

      Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

      Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.