Bug Report T298751
Visible to All Users

TokenLookUpEdit control generates InvalidOperationException while scrolling in certain scenarios

created 9 years ago

Hello,

I am using TokenLookUpEdit control in my project, I am facing an issue Exception) which seems to be triggered from the inner code of TokenLookupEdit control, following is the stack trace.

"Sequence contains no elements"
   at System.Linq.Enumerable.Last[TSource](IEnumerable`1 source)
   at DevExpress.Xpf.Editors.Internal.TokenEditorWrapLineMeasureStrategy.MeasureLinesOnScrollDown(Size constraint, TokenEditorLineInfo newOffsetLine)
   at DevExpress.Xpf.Editors.Internal.TokenEditorWrapLineMeasureStrategy.MeasureOldLines(Size constraint, Int32 newOffsetLineIndex, TokenEditorLineInfo newOffsetLine)
   at DevExpress.Xpf.Editors.Internal.TokenEditorWrapLineMeasureStrategy.Measure(Size constraint)
   at DevExpress.Xpf.Editors.Internal.TokenEditorPanel.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 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.Application.Run()
   at TokenLookUpEdit.App.Main() in d:\KSR\DevExpress Bugs\TokenLookup Edit\15.1.7\TokenLookUpEdit\TokenLookUpEdit\TokenLookUpEdit\obj\Debug\App.g.cs:line 0
   at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   at System.Threading.ThreadHelper.ThreadStart_Context(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 System.Threading.ThreadHelper.ThreadStart()

Steps to reproduce:

1- Execute the attached demo project.
2- I have added different students with Test long names, for test type "A" It will open a list, select one entry, then add multiple entries till the vertical scroll is enabled.
3- Now scroll down, as soon as the scroll reaches the bottom area you will see the application will crash with above exception and sometimes (ArgumentOutOfRangeException)

It looks like to be related to width of selected token.

Could you please let me know how to fix it?

Regards.

Comments (3)
DevExpress Support Team 9 years ago

    Hello,

    Thank you for providing the test project. However, I cannot replicate this issue on our side. I have attached a screencast illustrating my actions. Please take a moment to review it. Probably, I missed something essential.

    Thanks,
    Elliot

      Thanks Elliot for your reply. Surprisingly I can easily replicate this issue on my machine. I have tested it on 5 different machines. Having Windows 7 Enterprise (64 bit) and Windows Server 2012 (64 bit), .Net Framework is 4.5 and DexExpress controls version is 5.7.1. Moreover I have attached an animated Gif for the required steps.
      Please let me know about your environment settings (OS, .Net Framework etc) + any project code change (if you made).
      Regards

      DevExpress Support Team 9 years ago

        Hi Shahab,
        Thank you for the screencast. I have successfully reproduced the issue and passed this ticket to our developers for further research. Please stay tuned. We will notify you as soon as we make any progress.

        Answers

        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.

        Additional information:

        The fix is temporarily unavailable.

          Show previous comments (5)

            Hello Elliot,
            I have checked the latest hotfix, build number 15924. But issue still seems to be there, now its not every time, but it comes randomly. I have checked it on Windows 7-64 bit and Windows 2012 Server-64 bit. Same result for both operating systems.
            Thanks

            DevExpress Support Team 9 years ago

              We apologize for possible inconvenience. After additional testing your initial sample, we've found a stable way to reproduce the exception with the hotfix. For this, we need to quickly drag the scrollbar until its height becomes small. Then, if the bottom scrollbutton is pressed, the exception is raised - see the attached screencast. Can you confirm that this issue is the same as the one you reproduced?
              Our developers will fix the exception we've found. We will let you know once the fix is available.

                Thanks Ivan for your response, yes it looks like the same scenario. The similarity between your screencast and exception on my side is "shrinking of scroll", I have observed that whenever this happens it generates the exception (Pressing of scroll button is not necessary)
                Moreover I  think it also depends on adding sequence of tokens, If smaller tokens are added at start like in your screencast then this exception is raised, but if we add larger tokens at start then the control behaves in relatively stable way.
                Hope it helps to figure out the exact reason of issue.
                Thanks

                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.