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

Telerik.WinControls.RadControlAnimationTimer.Stop leading to NullReferenceException

9 Answers 128 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
B
Top achievements
Rank 1
B asked on 22 Dec 2012, 01:06 PM
I have a multi threaded single form WinForms application using mostly(all) Telerik controls. Recently i have experienced a problem that seems to be at random. Sometimes, when giving focus to the application it throws a NullReferenceException and causes the application to shutdown.

I captured the detail from the exception this time which has been pasted below. I found another post that may be related.

http://www.telerik.com/community/forums/winforms/general-discussions/net-runtime-2-0-error.aspx 

I have not always had this problem as it just appeared in the past few days. Some of the recent changes i have made that may or may not be related:

Recently upgraded to the latest controls package.
Added additional RadButtons
Added columns to an existing RadGridView's (I found another error here but wasn't able reproduce after i corrected it where my control was not being recognized at runtime.)

Also, although my application has multiple threads the error seems to be related to me giving the application focus or clicking on a button(or attempting to) and it doesn't seems to be related to any specific button, other thread changes\events.

Is anyone else experiencing this or know a solution? 

Thanks!

Exception Detail:
-----------------------------------------------------------------------------------------------------------------------------------
System.NullReferenceException was unhandled
  Message=Object reference not set to an instance of an object.
  Source=Telerik.WinControls
  StackTrace:
       at Telerik.WinControls.RadControlAnimationTimer.Stop()
       at Telerik.WinControls.ElementValuesAnimator.Stop()
       at Telerik.WinControls.ElementValuesAnimator.AnimationTimer_Tick(Object sender, EventArgs e)
       at Telerik.WinControls.RadControlAnimationTimer.OnTick(EventArgs e)
       at Telerik.WinControls.RadControlAnimationTimer.internalTimer_Tick(Object sender, EventArgs e)
       at System.EventHandler.Invoke(Object sender, EventArgs e)
       at System.Windows.Forms.Timer.OnTick(EventArgs e)
       at System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
       at Home_Automation_Server.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
       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.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: 

9 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 26 Dec 2012, 01:19 PM
Hi Brannon, 

Thank you for writing.

I would like to clarify that all UI controls in the .Net framework are NOT thread safe. This is a framework limitation and you should always use the Invoke method when accessing them from a thread different than the UI thread. 

The issue is related more to the Telerik Presentation Framework and it is not specific to any control. So, I cannot tell in which control it occurs. 

If this is a show stopper, you can solve the issue by disabling the animations. This can be done by setting the AnimationsEnabled property of AnimatedPropertySetting to false:
ThemeResolutionService.AllowAnimations = false;

I hope this helps.

Kind regards,
Peter
the Telerik team
Q3’12 of RadControls for WinForms is available for download (see what's new). Get it today.
0
B
Top achievements
Rank 1
answered on 26 Dec 2012, 01:51 PM
Hi,

Thank you for the workaround. I have not implemented it but soon will if i do not find another soluction. I do want to point out that although my application is multi-threaded i do not access any of the controls directly through the alternate threads. I always invoke the main UI thread in order to update the UI as necessary so i do not believe this is the issue or at least not yet. I'll trace the application today and see if i can find an instance where i'm attempting to update the controls from one of the other threads.

Thanks
0
Peter
Telerik team
answered on 27 Dec 2012, 02:59 PM
Hi Brannon,

Thank you for writing back and for the provided details.

You approach about the multi-threaded is correct. Please let me know the result of your findings.

Kind regards,
Peter
the Telerik team
Q3’12 of RadControls for WinForms is available for download (see what's new). Get it today.
0
B
Top achievements
Rank 1
answered on 01 Jan 2013, 04:11 PM
Hi,

It took me a little longer to get to it that i expected but i have traced the entire application and verified that i do not access any of the UI controls from my alternate thread. I have just two threads going at this point in an attempt to narrow down the problem - the UI and an alternate thread. The alternate thread does nothing more than receive data and processes the data finally calling a UI method once the data has been processed. When calling that method i check for invokerequired. Then, if the invoke is required i invoke the ui thread using a delegate. This functionality i just described has been in place for a long time without this issue. 

As i mentioned this started after a made a few UI changes by adding a button, column to a radgridview and a couple of other minor UI tweaks(they are accurately described above in this thread but i can't see them now). I'm fairly confident at this point that the issue started as a result of those actions but i can't seem to figure out exactly which one is causing it.  
0
Peter
Telerik team
answered on 04 Jan 2013, 11:17 AM
Hi Brannon,

Thank you for the writing back and for this clarification. 

Since we cannot reproduce the issue with our projects, I would kindly ask you to send me your project where the issue appears together with the steps that I need to take in order to reproduce it. This will allow me to investigate the issue and provide you with adequate and helpful assistance.

I am looking forward to your reply.

All the best,
Peter
the Telerik team
Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
0
B
Top achievements
Rank 1
answered on 01 Feb 2013, 02:28 PM
I wanted to update this thread and indicate that i finally found the issue. I had two closely named variables and had mistyped the code to access them which resulted in multiple instances of the main form and therefore causing the problem i reported. I'm not sure why it showed up when activating the visible main form but correcting that has resolved my problem. Thank you for assisting.
0
Peter
Telerik team
answered on 06 Feb 2013, 01:15 PM
Hi Brannon,

Thank you for sharing this information with us. I am happy that you resolved the issue.
If you have further questions, do not hesitate to contact us.

Greetings,
Peter
the Telerik team
Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
0
Francesco
Top achievements
Rank 1
answered on 08 May 2013, 02:23 PM
Hi everyone,
I have a similar issue. It's random. My scenario is: a radscheduler with a couple of radpanel and a radnavigator.

I've caught the stackstrace:

   at System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
   at System.RuntimeMethodHandle.InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
   at Telerik.WinControls.RadElementTree.CheckLicense()
   at Telerik.WinControls.RadElementTree..ctor(IComponentTreeHandler component)
   at Telerik.WinControls.ComponentThemableElementTree..ctor(IComponentTreeHandler owner)
   at Telerik.WinControls.RadControl.Construct()
   at Telerik.WinControls.RadControl..ctor()
   at Telerik.WinControls.UI.RadPopupControlBase..ctor(RadElement owner)
   at Telerik.WinControls.UI.RadItemsPopupControl..ctor(RadElement owner)
   at Telerik.WinControls.UI.RadDropDownMenu..ctor(RadElement ownerElement, RadDropDownMenu parentPanel)
   at Telerik.WinControls.UI.RadDropDownMenu..ctor()
   at Telerik.WinControls.UI.RadScheduler..ctor()
   at Microarea.MenuManager.Organizer.InitializeComponent() in C:\DevOFM\Standard\TaskBuilder\MagoNet\Organizer.Designer.cs:line 35
   at Microarea.MenuManager.Organizer..ctor(String authToken, CultureInfo culture) in C:\DevOFM\Standard\TaskBuilder\MagoNet\Organizer.cs:line 64

Is it that we didn't buy the license? it seems it's linked with the license check.

Thanks in advance,

Francesco Ricceri
Microarea SpA
0
Peter
Telerik team
answered on 13 May 2013, 12:25 PM
Hello Francesco,

Thank you for writing.

RadElementTree's CheckLicense method loads via reflection a dialog from Telerik.WinControls.UI.dll. The easiest way to fix issues from this type is to uninstall and reinstall the control suite. This will install our DLLs into the Global Assembly Cache (GAC) and the reflection from the CheckLicense method will find the Telerik.WinControls.UI.dll correctly.

Should you continue to experience this issue, please get back to us.

I hope this helps.

Kind regards,
Peter
the Telerik team
RadChart for WinForms is obsolete. Now what?
Tags
General Discussions
Asked by
B
Top achievements
Rank 1
Answers by
Peter
Telerik team
B
Top achievements
Rank 1
Francesco
Top achievements
Rank 1
Share this question
or