When appointment is extended/shrink for the first time after loading app, i get null ref exception, if i drag and drop it first and then try to expand

5 posts, 1 answers
  1. Colin
    Colin avatar
    19 posts
    Member since:
    Jun 2011

    Posted 19 Jun 2014 Link to this post

    Hi,

    I have created a database for the RadScheduleView following Telerik
    tutorials. I am able to create the database, save appointments with their
    categories, time markers etc.

    When I load the app, I have few appointments displayed
    correctly, I can double click to edit them, I can drag them around, and expand
    or shrink them. However there is one problem, if I load the app and the first
    thing I do is try to expand or shrink an appointment I get this:

     

    System.NullReferenceException was unhandled
      HResult=-2147467261
      Message=Object
    reference not set to an instance of an object.
    Source=Telerik.Windows.Controls.ScheduleView
      StackTrace:
           at
    Telerik.Windows.Controls.ScheduleViewBase.<>c__DisplayClass23.<GetDecorationBlocksForSlot>b__1f(IGroupItemInfo
    info)
           at
    System.Linq.Enumerable.WhereListIterator`1.MoveNext()
           at
    System.Linq.Enumerable.<SelectManyIterator>d__14`2.MoveNext()
           at
    System.Linq.Enumerable.<SelectManyIterator>d__14`2.MoveNext()
           at
    Telerik.Windows.Controls.CollectionExtensions.ForEach[T](IEnumerable`1 source,
    Action`1 action)
           at
    Telerik.Windows.Controls.HighlightPanel.MeasureOverride(Size availableSize)
           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
    MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
           at
    System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
           at
    System.Windows.Threading.Dispatcher.WrappedInvoke(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
    MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
           at
    System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
           at
    System.Windows.Threading.Dispatcher.WrappedInvoke(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
    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.DoDragDrop(IDataObject dataObject, IOleDropSource dropSource, Int32 allowedEffects, Int32[] finalEffect)
           at
    System.Windows.OleServicesContext.OleDoDragDrop(IDataObject dataObject,IOleDropSource dropSource, Int32 allowedEffects, Int32[] finalEffect)
           at
    System.Windows.DragDrop.OleDoDragDrop(DependencyObject dragSource, DataObjectdataObject, DragDropEffects allowedEffects)
           at System.Windows.DragDrop.DoDragDrop(DependencyObject dragSource, Object data, DragDropEffects allowedEffects)
           at
    Telerik.Windows.DragDrop.DragDropManager.DoDragDrop(DependencyObject dragSource, Object data, DragDropEffects allowedEffects, DragDropKeyStates
    initialKeyState, Object dragVisual, Point relativeStartPoint, Point dragVisualOffset)
           at
    Telerik.Windows.DragDrop.DragInitializer.StartDrag()
           at
    Telerik.Windows.DragDrop.DragInitializer.StartDragPrivate(UIElement sender)
           at Telerik.Windows.DragDrop.DragInitializer.DragSourceOnMouseMove(Object
    sender, MouseEventArgs e)
           at
    System.Windows.Input.MouseEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
           at
    System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
           at
    System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs
           at
    System.Windows.RouteItem.InvokeHandler(RoutedEventArgs routedEventArgs)
           at
    System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
           at
    System.Windows.EventRoute.InvokeHandlers(Object source, RoutedEventArgs args)
           at
    System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs
    args)
           at
    System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
           at
    System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
           at
    System.Windows.Input.InputManager.ProcessStagingArea()
           at
    System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
           at
    System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
           at
    System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y,
    Int32 wheel)
           at
    System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
           at
    System.Windows.Interop.HwndSource.InputFilterMessage(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.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
           at
    System.Windows.Threading.Dispatcher.WrappedInvoke(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
    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.TranslateAndDispatchMessage(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
    ScheduleViewTest.App.Main() in c:\Apps\TelerikDatabase\TelerikScheduleViewDatabase\ScheduleViewTest\obj\x86\Debug\App.g.cs:line
    0
           at System.AppDomain._nExecuteAssembly(RuntimeAssemblyassembly, String[] args)
           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()
      InnerException:

    This only happens if I try to extend or shrink First, if I drag
    and drop and then try to extend or shrink then its working properly, what
    settings are need to make it work properly?

    Kind Regards

  2. Colin
    Colin avatar
    19 posts
    Member since:
    Jun 2011

    Posted 20 Jun 2014 in reply to Colin Link to this post

    Hi,

    Are there any news on the above question? Ive added the logic for the recurrence now, and exactly the same happens, I can not expand or shrink any of the appointment, unless i first drag it on the screen.

    Kind Regards
  3. UI for WPF is Visual Studio 2017 Ready
  4. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 23 Jun 2014 Link to this post

    Hello Colin,

    I have tested our Binding to Database example for WPF uploaded here, but I did not manage to reproduce the reported issue. Could you give us more details on your approach, what is different in your project than the one I referenced? Any additional information you could provide will be of great help.

    I am looking forward to your reply.

    Regards,
    Yana
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
  5. Colin
    Colin avatar
    19 posts
    Member since:
    Jun 2011

    Posted 23 Jun 2014 in reply to Yana Link to this post

    Hi Yana,

    Actually there is not much difference, I am using Entity Framework 6.1 code first, and I think that the only thing.
    Please have a look at the Example app, and tell me what needs to be changed. This contains 4 projects,

    -         CreateDatabase, is just a console app which
    drops and creates a database, only when I want to quickly clear the data for
    testing, or I made change to the model and want them to be applied (without
    migrations because im just testing at the moment)

    -         TelerikScheduleViewDatabase (contains the POCOs and the helper classes)

    -        ScheduleViewTest – is a wpf app which I build to test the ScheduleView behaviour with the above POCOs and database (code behind).

    -         TestApp – is the wpf part that I took from the project you provided in the link, it is to test to see if your project would work (mvvm).

    If you run any of the wpf apps, and add some appointments save them (the first one saves when you add an appointment and click ok, the second one has a save button on the scheduleView), close the app and run it again, then try to expand that appointment you created you will get a null reference axception, however if you drag and drop it first and then try to expand that’s absolutely fine and it will work. The only exception from that is in Timeline view I can expand the appointment straight after loading the app.

    Please have a look at the Example app, and tell me what needs to be changed.

    Kind Regards
  6. Answer
    Yana
    Admin
    Yana avatar
    4554 posts

    Posted 25 Jun 2014 Link to this post

    Hi Colin,

    I am pasting the reply from the support ticket regarding the same issue:

    The reason for the reported exception is that initially the appointments do not have their TimeZone property set. In your SqlAppointment.cs class (inside TelerikScheduleViewDatabase project), you should implement the TimeZone property like this:


    private TimeZoneInfo timeZone;
     
    public TimeZoneInfo TimeZone
    {
        get
        {
            if (this.timeZone == null)
            {
                return TimeZoneInfo.Local;
            }
            return this.timeZone;
        }
        set
        {
            if (this.timeZone != value)
            {
                this.timeZone = value;
                this.OnPropertyChanged("TimeZone");
            }
        }
     }

    This should fix the error.

    Regards,
    Yana
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
Back to Top
UI for WPF is Visual Studio 2017 Ready