NullReferenceException caused by CurrencyManager/DataView/RecordManager

A

Arno Huetter

Hi there,

under certain conditions I keep on receiving a NullReferenceException
in DataView.IsOriginalVersion():

system.data.dll!System.Data.DataView.IsOriginalVersion(int index = 0)
+ 0x3c bytes
system.data.dll!System.Data.DataRowView.SetColumnValue(System.Data.DataColumn
column = {System.Data.DataColumn}, System.Object value = 4) + 0x4c
bytes
system.data.dll!System.Data.DataColumnPropertyDescriptor.SetValue(System.Object
component = {System.Data.DataRowView}, System.Object value = 4) + 0x36
bytes
system.windows.forms.dll!System.Windows.Forms.BindToObject.SetValue(System.Object
value = 4) + 0x84 bytes
system.windows.forms.dll!System.Windows.Forms.Binding.PullData() +
0xf8 bytes

The exception is caused by the fact that DataView calls the indexer on
its DataTable's RecordManager, and expects it to return a DataRow, but
receives <null>. RecordManager's DataRow-array "rows" is emptied
before due to a call to CurrencyManager.EndCurrentEdit() (this
CurrencyManager handles Winforms databinding to the affected DataSet),
hence rows[0] contains <null>. CurrencyManager.EndCurrentEdit() is
necessary to pump all proposed or not-refreshed values into current
values.

I haven't found any further clues regarding this issue, but somehow
this DataSet seems to be in an inconsistent state after the call to
CurrencyManager.EndCurrentEdit(). Has someone experienced a similar
behaviour? What might be the reason, or how can it be worked around?

This only happens in certain constellations (in our case in one out of
douzands of WinForms which are bound to DataSets).

Thank you.

Kind regards,
Arno Huetter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top