locked
How to fix this error "Object reference not set to an instance of an object"

    Question

  •  Hi there
    I am getting this error and I can't figure out on how to fix this.I am getting this error "Object reference not set to an instance of an object. Use the "new" keyword to create and object instance" but how do I do this at that line of code # 22
    1 private void bindingNavigatorAddNewItem_Click(object sender, EventArgs e)  
    2         {  
    3             sndbutton.Play();  
    4             
    5             Bass.BASS_StreamFree(_stream);  
    6  
    7             this.folderBrowserDialog1.ShowNewFolderButton = false;  
    8             DialogResult result = this.folderBrowserDialog1.ShowDialog();  
    9             if (result == DialogResult.OK)  
    10             {  
    11                 // retrieve the name of the selected folder  
    12                 DirectoryInfo dir = new DirectoryInfo(this.folderBrowserDialog1.SelectedPath);  
    13  
    14                 albumTitleTextBox.Text = dir.Name;  
    15                   
    16                                   
    17                 //Now to get every song in the folder  
    18                 foreach (FileInfo fi in dir.GetFiles())  
    19                 {  
    20                     if (fi.Extension == ".mp3")  
    21                     {                          
    22                         songbindingNavigator.BindingSource.AddNew();                          
    23                         songUrlTextBox.Text = fi.FullName;  
    24                         songTextBox.Text = fi.ToString();  
    25                     }        
    26                 }  
    27  
    28                 _stream = Bass.BASS_StreamCreateFile(songUrlTextBox.Text, 0, 0, BASSFlag.BASS_SAMPLE_FLOAT | BASSFlag.BASS_STREAM_PRESCAN);  
    29                                   
    30                 // get some channel info  
    31                 BASS_CHANNELINFO info = new BASS_CHANNELINFO();  
    32                 Bass.BASS_ChannelGetInfo(_stream, info);  
    33  
    34                 // display the tags...  
    35                 TAG_INFO tagInfo = new TAG_INFO(songUrlTextBox.Text);  
    36                 if (BassTags.BASS_TAG_GetFromFile(_stream, tagInfo))  
    37                 {  
    38                     // and display what we get  
    39                     this.albumTitleTextBox.Text = tagInfo.album;  
    40                     this.artistTextBox.Text = tagInfo.artist;  
    41                     this.categoryTextBox.Text = tagInfo.genre;  
    42                     this.yearTextBox.Text = tagInfo.year;  
    43                 }               
    44             }  
    45             else 
    46             {  
    47                 //If cancel erase row  
    48                 sndbutton.Play();  
    49                 this.firstBindingNavigator.BindingSource.CancelEdit();  
    50             }  
    51         } 
    It was working find before I received a update from microsoft then the problem started .
    Thursday, December 18, 2008 10:17 AM

Answers

  • Ok got it I just deleted my dataset and build a new one and the problem is fix don't know why but it work. So if someone could tell me why that solution work because for me it is a mistery
    • Marked as answer by superl Thursday, December 18, 2008 3:45 PM
    Thursday, December 18, 2008 3:45 PM