This is a migrated thread and some comments may be shown as answers.

Rectangle in Gridview and Coded UI Test

9 Answers 227 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Sandy
Top achievements
Rank 1
Sandy asked on 08 Jul 2010, 04:42 PM
Hello -
We have a column in a radgridview that is using a rectangle in the data template (WPF 3.5 app - Moving to .NET 4.0 is not a option right now.). This works fine normally, but running a VS 2010 Coded UI Test against the app when this grid is displayed causes our application to crash due to a null reference exception being thrown. Please advise.

Note: This causes our application to crash during QTP automated UI tests (what we normally use for automated UI testing) as well, so our automated testing in on hold until a fix is found.

By the way, UISpy doesn't like this either, but Snoop doesn't seem to have a problem with it.
Thanks.

GridView Column code:

<

 

telerik:GridViewColumn Header="" IsSortable="False" IsFilterable="False" TextAlignment="Center">

 

 

 

<telerik:GridViewColumn.CellTemplate>

 

 

 

<DataTemplate>

 

 

 

<Rectangle Height="18" Width="18"

 

 

HorizontalAlignment="Center" VerticalAlignment="Center"

 

 

Fill="AliceBlue"/>

 

 

 

</DataTemplate>

 

 

 

</telerik:GridViewColumn.CellTemplate>

 

 

 

</telerik:GridViewColumn>

 

 

 

Exception detail:

Event Type: Error
Event Source: RATS 3.0
Event Category: None
Event ID: 100
Date:  7/8/2010
Time:  11:26:50 AM
User:  N/A
Computer: 
Description:
Timestamp: 08-Jul-2010 3:26:50 PM
Message: HandlingInstanceID: c590513b-d517-41bf-88b5-b1304b1daab7
An exception of type 'System.NullReferenceException' occurred and was caught.
-----------------------------------------------------------------------------
07/08/2010 11:26:50
Type : System.NullReferenceException, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
Message : Object reference not set to an instance of an object.
Source : PresentationCore
Help link :
Data : System.Collections.ListDictionaryInternal
TargetSite : Void EnsureChildren()
Stack Trace :    at System.Windows.Automation.Peers.AutomationPeer.EnsureChildren()
   at System.Windows.Automation.Peers.AutomationPeer.UpdateChildren()
   at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
   at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
   at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
   at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
   at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
   at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
   at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
   at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
   at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
   at System.Windows.ContextLayoutManager.fireAutomationEvents()
   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.AnimatedRenderMessageHandler(Object resizedCompositionTarget)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
   at System.Windows.Threading.DispatcherOperation.InvokeImpl()
   at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
   at System.Threading.ExecutionContext.runTryCode(Object userData)
   at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
   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, Boolean isSingleParameter)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter)
   at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg)
   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.Threading.Dispatcher.Run()
   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 WpfShell.App.Main() in C:\IS\TFSProd\CSS.Underwriting\Main\Rats3\Client\WpfShell\obj\Debug\App.g.cs:line 0

 

 

9 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 09 Jul 2010, 06:35 AM
Hello,

 Can you post more info about the grid version? Is it our latest service pack or our latest internal build or even our Q2 Beta? Can you post also what will happen if you remove this Rectangle from the template?

Best wishes,
Vlad
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Sandy
Top achievements
Rank 1
answered on 09 Jul 2010, 01:22 PM
We are using version 2010.1.422.35.

And when we remove the rectangle from the test runs normally. That's how we know the rectangle is the issue.

You can easily reproduce this issue by running UI Spy against a WPF app that contains a grid with a cloumn that has a data template that contains a rectangle (the code from the post).

One of our developers dig some further digging using .NET Reflector, and here's what he found:

Apparently the Visual Studio Coded UI Test  – like UI Spy – makes use of System.Windows.Automation to do its work.  Our problem appears to be happening within the Telerik.Windows.Controls.GridView.Automation.GridViewCellAutomationPeer code as part of the Telerik Grid.  Specifically:

 

The System.Windows.Automation code calls

        private void EnsureChildren()

        {

            if(!_childrenValid)

            {

                _children = GetChildrenCore();

                if (_children != null)

                {

                    int count = _children.Count;

                    for (int i = 0; i < count; ++i)

                    {

                        _children[i]._parent = this;

                        _children[i]._index = i;

                        _children[i]._hwnd = _hwnd;

                    }

                }

                _childrenValid = true;

            }

        }

The blue line throws a null reference exception.  _children has been populated with a single item as a result of the GetChildrenCore call, and this single item is null, which looks suspicious. 

 

Examining Telerik’s code for GetChildrenCore:

protected override List<AutomationPeer> GetChildrenCore()

{

    List<AutomationPeer> list = new List<AutomationPeer>();

    if (this.OwnerCell != null)

    {

        if (this.OwnerCell.IsInEditMode)

        {

            GridViewEditorPresenter presenter = this.OwnerCell.Content as GridViewEditorPresenter;

            if (presenter != null)

            {

                FrameworkElement element = presenter.Content as FrameworkElement;

                if (element != null)

                {

                    list.Add(UIElementAutomationPeer.CreatePeerForElement(element));

                }

            }

            return list;

        }

        FrameworkElement content = this.OwnerCell.Content as FrameworkElement;

        if (content != null)

        {

            list.Add(UIElementAutomationPeer.CreatePeerForElement(content));

        }

    }

    return list;

}

Looking at the properties of the “this” item, it is not in Edit Mode, which means that whole block can be skipped.  Looking at this.OwnerCell.Content as FrameworkElement shows that it does return a value (a System.Windows.Shapes.Rectangle, to be specific).  It appears that the call to UIElementAutomationpeer.CreatePeerForElement(content) is returning null, which is promptly being stuffed into the list being returned, which then leads to our exception.  Our thought is that Telerik may want to examine the return value before putting it into the list, and if it is null, to not do so.

0
Shawn Stephens
Top achievements
Rank 1
answered on 16 Jul 2010, 05:06 PM
We too are experiencing this error on various machines with both Windows XP and Windows 7 installed. If we run as admin in Windows 7 on the affected machines, it does not occur. It seems to occur anywhere we use telerik controls in our grid columns.

I don't actually have the problem on my machine, but I've found I too can duplicate by using UISpy with event tracing started. Has anyone from Telerik been able to duplicate and possibly resolve this issue?
System.NullReferenceException: Object reference not set to an instance of an object.
   at System.Windows.Automation.Peers.AutomationPeer.EnsureChildren()
   at System.Windows.Automation.Peers.AutomationPeer.UpdateChildrenInternal(Int32 invalidateLimit)
   at System.Windows.Automation.Peers.AutomationPeer.UpdateChildren()
   at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
   at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
   at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
   at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
   at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
   at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
   at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
   at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
   at System.Windows.ContextLayoutManager.fireAutomationEvents()
   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 MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.DispatcherOperation.InvokeImpl()
   at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
   at System.Threading.ExecutionContext.runTryCode(Object userData)
   at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
   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 MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.InvokeImpl(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.Threading.Dispatcher.Run()
   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 Ticketing.UI.App.InitMainForm()
0
Sandy
Top achievements
Rank 1
answered on 16 Jul 2010, 05:12 PM
Shawn -
I actually ended up submitting a support ticket for this on Monday (Jul 12th). I'm still waiting for a resolution.
0
Shawn Stephens
Top achievements
Rank 1
answered on 16 Jul 2010, 08:01 PM
Hi Sandy,

Do you have the title of the ticket? I'm trying to find it in the Telerik Public Issue Tracking System.

Thanks,
Shawn
0
Sandy
Top achievements
Rank 1
answered on 16 Jul 2010, 08:05 PM
Shawn,
The title is "Coded UI Test - Null Reference Exception".

--Sandy
0
Milan
Telerik team
answered on 20 Jul 2010, 02:03 PM
Hello Sandy Lamoureux,

We are still investigating the problem. We will try to give you more information by tomorrow evening.

Thank you for your patience.


Regards,
Milan
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Shawn Stephens
Top achievements
Rank 1
answered on 20 Jul 2010, 02:41 PM
A colleague also added a support ticket and sample project that can be used to duplicate this issue by starting automation monitoring in UI Spy.

Telierk team,

The ticket is titled "AutomationPeer errors from RadGridView edits" and is at
"http://www.telerik.com/account/support-tickets/view-ticket.aspx?threadid=329474"

Regards,
Shawn
0
Milan
Telerik team
answered on 22 Jul 2010, 04:02 AM
Hello Shawn Stephens,

We managed to fix the problem and the fix will be included in our Internal Build this Friday.

I am now closing this forum thread and I would like to ask you to continue our discussion in the support thread if necessary. 


Kind regards,
Milan
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
Sandy
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Sandy
Top achievements
Rank 1
Shawn Stephens
Top achievements
Rank 1
Milan
Telerik team
Share this question
or