Home Forums WPF controls Xceed DataGrid for WPF Out Of Exception Error when Cell is Visible in Display with Unfriendly Text

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • dar100111
    Participant
    Post count: 11
    #45044 |

    I have been scratching my head on this for a few days now. I have about 2000 rows that pull back from a database into Xceed Datagrid. There are a couple of rows that when I scroll to a certain column, causes an application crash. The name of this column. The text that it does not like displaying is below.

    Pending redirect – 999 East Royal Lane / #110 / Irving TX 75039

    This crash only comes when this column is displayed, and I scroll to this piece of text when it’s in view. There is no special functionality of this column. When my users click on the rows it populates some of these handwritten fields in a second datagrid on the page. If I click on this row, this same text will populate below and cause this same crash. It seems the crash only on a few rows in my whole dataset. I was able to delete one from the database like this and it has no problem displaying a different piece of text from this column. I’m trying to figure out if this is something I’m doing wrong or if it’s a legitimate issue.

    I’ve tried looking into if any special characters are causing this issue.
    This is a Field that pulls from a database where user’s type info into a website. Looked at &   characters. Can’t put my finger on it. If anyone has any suggestions on how to prevent, would be greatly appreciated! Thanks in advance.

    Here is the only thing I can see on the stack.

    
    Unhandled Exception: The thread 0x560 has exited with code 0 (0x0).
    The thread 0x4fbc has exited with code 0 (0x0).
    System.NullReferenceException: Object reference not set to an instance of an object.
       at Xceed.Wpf.Controls.TextBlockLite.<GetRanges>d__e.MoveNext()
       at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable

    1 source)
    at Xceed.Wpf.Controls.TextBlockLite.TruncateGlyphLine(GlyphLine line, TextWrapping wrapping, Double maxWidth, GlyphLine& rest)
    at Xceed.Wpf.Controls.TextBlockLite.TrimGlyphLines(IList1 lines, Size constraint, TextTrimming trimming, TextWrapping wrapping, GlyphBlock ellipsis, IList1& newLines, Size& newSize)
    at Xceed.Wpf.Controls.TextBlockLite.CreateBlock(GlyphBlock block, Size constraint, TextTrimming trimming, TextWrapping wrapping, GlyphBlock ellipsis)
    at Xceed.Wpf.Controls.TextBlockLite.UpdateRenderBlock(Size constraint)
    at Xceed.Wpf.Controls.TextBlockLite.MeasureOverride(Size constraint)
    at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
    at System.Windows.UIElement.Measure(Size availableSize)
    at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
    at System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint)
    at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
    at System.Windows.UIElement.Measure(Size availableSize)
    at System.Windows.ContextLayoutManager.UpdateLayout()
    at System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg)
    at System.Windows.Media.MediaContext.InvokeOnRenderCallback.DoWork()
    at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
    at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
    at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
    at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
    at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
    at System.Windows.Threading.DispatcherOperation.InvokeImpl()
    at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
    at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
    at MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext, ContextCallback callback, Object state)
    at System.Windows.Threading.DispatcherOperation.Invoke()
    at System.Windows.Threading.Dispatcher.ProcessQueue()
    at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
    at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
    at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
    at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
    at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
    at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
    at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
    at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
    at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
    at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
    at System.Windows.Application.RunDispatcher(Object ignore)
    at System.Windows.Application.RunInternal(Window window)
    at System.Windows.Application.Run(Window window)
    at System.Windows.AThe program ‘[18164] CBA Management Suite.exe’ has exited with code 0 (0x0).
    pplication.Run()
    at CBAMS.App.Main()
    `

    Fawzi [Xceed]
    Member
    Post count: 722

    Hi,

    The presence of line breaks (‘\ n’) in the string, could be the trigger of this problem. This should be fixed in our upcoming service release (should be available within few weeks from now).

    In the meantime, a possible workaround is to specify a CellContentTemplate that will use a TextBlock. For example for the column “Col1”:

    <Xcdg: DataGridControl.Columns>
       <xcdg: Column FieldName = “Col1”>
         <Xcdg: Column.CellContentTemplate>
           <DataTemplate>
             <TextBlock Text = “{Binding}” />
           </ DataTemplate>
         </xcdg:Column.CellContentTemplate>
       </ Xcdg: Column>
    </xcdg:DataGridControl.Columns>

    If the problem is not caused by the presence of the ‘\ n’ character, we would like to have a list of all characters in the text causing the problem in order to attempt to reproduce the issue and have a closer look.

    dar100111
    Participant
    Post count: 11

    Update.

    I found out these text fields have newline chars in the Oracle DB2 database. CHR(10) and CHR(13) if anyone is ever having issues with this.

    Is there a way to prevent errors like this in the datagrid when there are special characters in the fields?

    In the meantime I have replaced those characters in the queries that pull but would be great to find a better approach on the Datagrid to prevent critical errors like this one!

    dar100111
    Participant
    Post count: 11

    Hi Fawzi! Thanks for the insite. Looks like we posted at the same time. Great to hear there is a fix incoming!

    Diane [Xceed]
    Moderator
    Post count: 1353

    The following is fixed in the latest release (v6.5):

    “A NullReferenceException is no longer thrown by the TextBlockLite control.”

    Download link:
    https://xceed.com/latest-xceed-datagrid-for-wpf

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.