Maybe I'm just doing something wrong, I have no idea.
/////////////////////////////////////////////////////////////////////////////
var rates = from rate in MainForm.readData.Rates
orderby rate.ValidFrom descending
select rate;
int counter = 1;
foreach (CViwer.Rate row in rates)
{
NBand band ;
NExplorerBar explorerBar = new NExplorerBar();//NullReferenceException
Console.WriteLine(counter.ToString());
counter++;
bool yearExists = false;
foreach (Control c in panelBar.Controls)
{
NBand cBand = (NBand)c;
if (cBand.Caption == row.ValidFrom.Year.ToString())
{
band = cBand;
explorerBar = (NExplorerBar)band.Tag;
yearExists = true;
break;
}
}
if (!yearExists)
{
band = new NBand();
band.Caption = row.ValidFrom.Year.ToString();
band.TextAlign = HorizontalAlignment.Center;
panelBar.Controls.Add(band);
explorerBar = new NExplorerBar();
explorerBar.Dock = DockStyle.Fill;
band.Controls.Add(explorerBar);
band.Tag = explorerBar;
}
NExpander nexpender = new NExpander();
nexpender.Text = "Expander " + row.Id.ToString();
Rates ratesForm = new Rates();
nexpender.Height = ratesForm.Height + 35;
ratesForm.Location = new Point(0, 30);
nexpender.Controls.Add(ratesForm);
nexpender.State = ExpanderState.Collapsed;
explorerBar.Controls.Add(nexpender);
}
}
A first chance exception of type 'System.NullReferenceException' occurred in Nevron.Presentation.dll
System.Transactions Critical: 0 :
http://msdn.microsoft.com/TraceCodes/System/ActivityTracing/2004/07/Reliability/Exception/UnhandledUnhandled exceptionCViwer.vshost.exeSystem.NullReferenceException, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089Object reference not set to an instance of an object. at Nevron.UI.WinForm.Controls.NSkinManager.lIIIll111()
at Nevron.UI.WinForm.Controls.NSkinManager.UnregisterSkinnableInstance(INSkinnableControl control)
at Nevron.UI.WinForm.Controls.NExplorerBar.PerformDispose(Boolean disposing)
at Nevron.UI.WinForm.NControl.Dispose(Boolean disposing)
at System.ComponentModel.Component.Finalize()System.NullReferenceException: Object reference not set to an instance of an object.
at Nevron.UI.WinForm.Controls.NSkinManager.lIIIll111()
at Nevron.UI.WinForm.Controls.NSkinManager.UnregisterSkinnableInstance(INSkinnableControl control)
at Nevron.UI.WinForm.Controls.NExplorerBar.PerformDispose(Boolean disposing)
at Nevron.UI.WinForm.NControl.Dispose(Boolean disposing)
at System.ComponentModel.Component.Finalize()/////////////////////////////////////////////////////////////////////////////
It will happen every time at a different spot anywhere after 200 as far as i can see.