Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Shift+Click on Item results in Null Ref (Read 5941 times)
tomk
YaBB Newbies
*
Offline


Yaos!

Posts: 29
Joined: Apr 25th, 2006
Shift+Click on Item results in Null Ref
Aug 16th, 2006 at 12:37pm
Print Post  
[Sorry if this is a duplicate.  I hit post but after refreshing the screen several times I did not see my previous post]

We are getting a Null Reference exception when a use Shift+Clicks an Item in the Timetable grid.  We have a custom item class that derives from appointment.  We did not however override the LoadFrom or SaveTo serialization methods, nor are we registering this new Item class with the Schedule.  We don't intend on using this functionality as we are SOA and persist everything server side.  From the call stack it looks like it might be a problem that we are not providing clone and/or serialization codes?  How should we get past this error?  Any way to turn off this feature?

Call stack:
Message:    "Object reference not set to an instance of an object."

Source:     "Calendar"
Stack:

   at MindFusion.Scheduling.Appointment.Clone()

   at MindFusion.Scheduling.WinForms.Calendar.OnMouseDown(MouseEventArgs e)

   at System.Windows.Forms.Control.WmMouseDown(Message& m, MouseButtons button, Int32 clicks)

   at System.Windows.Forms.Control.WndProc(Message& m)

   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)

   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)

   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


Thanks again
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Shift+Click on Item results in Null Ref
Reply #1 - Aug 16th, 2006 at 1:12pm
Print Post  
Yes, it is required to override the Clone method in your custom class if you are going to support interactive item cloning. You can however disable item cloning by setting Calendar.ItemCloneKey to Keys.None.

Anyway, I tried to reproduce the bug here with an empty custom class and was not successful. The cloning works fine, though the clone is of type MindFusion.Scheduling.Appointment instead of my custom class, because the calendar invokes the Clone method of the Appointment class. I will appreciate it if you can send me the source code of your custom appointment, so that I can check what is wrong.

Meppy
  
Back to top
 
IP Logged
 
tomk
YaBB Newbies
*
Offline


Yaos!

Posts: 29
Joined: Apr 25th, 2006
Re: Shift+Click on Item results in Null Ref
Reply #2 - Aug 16th, 2006 at 3:58pm
Print Post  
Ok, I changed ItemCloneKey to None (and for good measure ItemChangeRefKey to None also - it turns out Alt+Click would also cause a runtime error).

Unfortunately this also generates a Null Ref. runtime error, although the stack is different, whenever I click an Item in the timetable:

   at MindFusion.Scheduling.WinForms.ItemTool..ctor(Calendar calendar, Item active, Item[] items, ItemToolAction action, Point initialMouse, TimeSpan minLength, Boolean canChangeReference)
   at MindFusion.Scheduling.WinForms.Calendar.OnMouseDown(MouseEventArgs e)
   at System.Windows.Forms.Control.WmMouseDown(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

I will send you some code separately so you can take a look at the custom item class and maybe figure out what is going on.
In the meantime I will set the clone key back to shift, because at least then I don't get an unhandled thread exception when I click without having a modifier key pressed. (Note that ctl+click never seems to cause an error).
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Shift+Click on Item results in Null Ref
Reply #3 - Aug 17th, 2006 at 5:48am
Print Post  
I have investigated your code and I have found the source of the troubles. In your custom appointment you override the Contacts collection and return null in it. Planner.NET always assumes though that the Appointment.Contact property references a valid ContactCollection object. For example, when an item is being cloned its contact collection is cloned too without checking whether it is null.

If the logic of your appointment does not include associated contacts, you can return an empty collection in your Contacts property, or best of all, don't override the Contacts property at all.

Let me know if this solution works for you.

Meppy
  
Back to top
 
IP Logged
 
tomk
YaBB Newbies
*
Offline


Yaos!

Posts: 29
Joined: Apr 25th, 2006
Re: Shift+Click on Item results in Null Ref
Reply #4 - Aug 24th, 2006 at 5:15pm
Print Post  
Thank you.  This solved our issue with modifier key + click events.  We decided not to override the property as setting it to null caused this problem.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint