.net – Why Visual Studio opens internals files on debugging mode?


I have a form (inheriting from a custom form class) with a checklistbox controls.

That i populate as this:

Dim strCategoryQuery As String
Dim strCategoryHashtagsQuery As String
Dim daCategoryHashtags As New MySqlDataAdapter

dtCategoryHashtags.Clear()
strCategoryHashtagsQuery = "SELECT CATEGORIE_LIBELLE FROM T_REF_CATEGORIES"
daCategoryHashtags = New MySqlDataAdapter(strCategoryHashtagsQuery, OpenConnexion)
daCategoryHashtags.Fill(dtCategoryHashtags)

Me.clbHashtagSrchCategory.DataSource = dtCategoryHashtags
Me.clbHashtagSrchCategory.DisplayMember = "CATEGORIE_LIBELLE"

On debug mode, VS opens CheckedListBox.cs and stopped on the specific line above, only for this checklistbox. Error message is: System.NullReferenceException : ‘Object reference not set to an instance of an object.’

protected override void RefreshItems()
{
    Hashtable hashtable = new Hashtable();
    for (int i = 0; i < Items.Count; i++)
    {
        hashtable[i] = CheckedItems.GetCheckedState(i);
    }
    base.RefreshItems();
    for (int j = 0; j < Items.Count; j++)
    {
        /// HERE IT STOPS 
        CheckedItems.SetCheckedState(j, (CheckState)hashtable[j]);
    }
}

If i hit F5 key, execution and everything goes well and dtCategoryHashtags is not nothing.
The custom form class inherited is only used to set icons and images…

Leave a Reply

Your email address will not be published. Required fields are marked *