Nullreference Exception... cant find where it comes from.


Author
Message
Philipp Guntermann
Philipp Guntermann
StrataFrame User (205 reputation)StrataFrame User (205 reputation)StrataFrame User (205 reputation)StrataFrame User (205 reputation)StrataFrame User (205 reputation)StrataFrame User (205 reputation)StrataFrame User (205 reputation)StrataFrame User (205 reputation)StrataFrame User (205 reputation)
Group: Forum Members
Posts: 141, Visits: 263
hi,

on a specific form i get the nullreference exceptionb below, (only) when i perform the following steps:

1. Delete records, untill none left.

2. Add new record

3. Save new record.

After that i get the exception. However, even tho it sais it could not save the data, by the time it shows the

exception, it has saved the data into the db (without any errors/missing values). When i then close the exception window, everything is fine, i then need to click the save button again, and 1 out of ~3 times, it will then not show the exception.

The Exception i get is the following:

BusinessLayerException
  An error occurred while saving an the data to the server.
NullReferenceException
  Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.

Source     : MicroFour StrataFrame Business

Stack Trace:
   bei System.Windows.Forms.Binding.SetPropValue(Object value)
   bei System.Windows.Forms.Binding.PushData(Boolean force)
   bei System.Windows.Forms.BindingManagerBase.PushData(Boolean& success)
   bei System.Windows.Forms.BindingManagerBase.PushData()
   bei System.Windows.Forms.PropertyManager.OnCurrentChanged(EventArgs ea)
   bei System.Windows.Forms.BindToObject.PropValueChanged(Object sender, EventArgs e)
   bei MicroFour.StrataFrame.Business.BusinessLayer.SaveByForm(Boolean Transactional, String TransactionKey)
   bei MicroFour.StrataFrame.UI.Windows.Forms.BaseForm.Save(Boolean Transactional, String TransactionKey)
   bei MicroFour.StrataFrame.UI.Windows.Forms.BaseForm.Save()
   bei MicroFour.StrataFrame.UI.Windows.Forms.MaintenanceFormToolStrip.cmdSave_Click(Object sender, EventArgs e)
   bei System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
   bei System.Windows.Forms.ToolStripButton.OnClick(EventArgs e)
   bei System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
   bei System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
   bei System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)
   bei System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)
   bei System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
   bei System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   bei System.Windows.Forms.Control.WndProc(Message& m)
   bei System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   bei System.Windows.Forms.ToolStrip.WndProc(Message& m)
   bei System.Windows.Forms.Control.ControlNativewindow.OnMessage(Message& m)
   bei System.Windows.Forms.Control.ControlNativewindow.WndProc(Message& m)
   bei System.Windows.Forms.Nativewindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

as said, it only happens when adding a new record after i deleted all records. and even tho it shows the exception, in theory it does everything right.

So my main question propably is, when do theese events in the businesslayer get triggered:

   bei System.Windows.Forms.Binding.SetPropValue(Object value)
   bei System.Windows.Forms.Binding.PushData(Boolean force)
   bei System.Windows.Forms.BindingManagerBase.PushData(Boolean& success)
   bei System.Windows.Forms.BindingManagerBase.PushData()

?

Reply
Edhy Rijo
E
StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Phillipp,

This thread is a bit old, but I just been fighting this very same issue getting this weird NullReferenceException not telling me which field was being triggering the error.

In my case I also have a DateTimePicker, but its value was being generated via the BO.SetDefaultValues() and in the BO, this datetime field was part of the Required fields collection.  I moved setting the default value to the BO.BeforeSave() and then I started getting this weird error, it looks like that the required field collection is validated somewhere before the bo.BeforeSave() triggering the error when saving the bo which is wrong because I was setting the value of the field right in the bo.BeforeSave().

Anyway, hope this help somebody else. Smile

Edhy Rijo

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search