Thread: Overflow exception unhandles

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Nov 2008
    Posts
    222

    Question Overflow exception unhandles

    hi all,



    Code:
    private void FocusOver(object sender, System.EventArgs e)
            {
                this.lvItem.SubItems[2].Text = editBox.Text;
                //Insert into registry [IMPORTANT]
                ListViewItem selectedItem = this.lvFiles.SelectedItems[0];
                string nodeFullPath = "";
                string keyName = selectedItem.Text.ToString();
                nodeFullPath = nodePath(this.tvFolders.SelectedNode.FullPath.ToString());
                          
                if (this.lvItem.SubItems[1].Text == "STRING")
                {
                    ManagedRegistry.Delete(nodeFullPath, selectedItem.Text);
                    ManagedRegistry.WriteKeyString(nodeFullPath, keyName, editBox.Text);
                }
                if (this.lvItem.SubItems[1].Text == "INTEGER")
                {
                    int intValue = 0;
                    intValue = (int)Convert.ToInt32(editBox.Text);
                    ManagedRegistry.Delete(nodeFullPath, selectedItem.Text);
                    ManagedRegistry.WriteKeyInteger(nodeFullPath, keyName, intValue);
    
                }
                if (this.lvItem.SubItems[1].Text == "BINARY")
                {
                    byte[] binaryValue = new byte[10];
                   
                   
                    for(int i = 0 ; i <10 ; i++)
                    {
                        binaryValue[i] = Convert.ToByte(editBox.Text)); 
                   
    
                    }
                    ManagedRegistry.Delete(nodeFullPath, selectedItem.Text);
                    ManagedRegistry.WriteKeyBinary(nodeFullPath, keyName, binaryValue);
                    
                } 
                
                InitListView(this.tvFolders.SelectedNode);
                EnumerateHBRegNode(this.tvFolders.SelectedNode);
                this.lvFiles.Refresh();
                editBox.Hide();
               
               
            }
    line which gives overflow exception unhandled is binaryValue[i] = Convert.ToByte(editBox.Text));

    wen i built it and run in MSC#2008 express edition, it shows following error. Also it says cannot implicity convert 'int'. use explicit (did u miss casting?)

    See the end of this message for details on invoking
    just-in-time (JIT) debugging instead of this dialog box.

    ************** Exception Text **************
    System.NullReferenceException: Object reference not set to an instance of an object.
    at Registry.RegMainWin.subMenuModify_Click(Object sender, EventArgs e) in C:\Documents and Settings\leo\Desktop\RegEdit\RegEdit.cs:line 2216
    at System.Windows.Forms.MenuItem.OnClick(EventArgs e)
    at System.Windows.Forms.MenuItem.MenuItemData.Execute ()
    at System.Windows.Forms.Command.Invoke()
    at System.Windows.Forms.Command.DispatchID(Int32 id)
    at System.Windows.Forms.Control.WmCommand(Message& m)
    at System.Windows.Forms.Control.WndProc(Message& m)
    at System.Windows.Forms.ListView.WndProc(Message& m)
    at System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message& m)
    at System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message& m)
    at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)








    PLS help me with an optimal solution, as am new to c# programming.
    Last edited by leo2008; 11-22-2008 at 06:28 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Exception handling in a large project
    By EVOEx in forum C++ Programming
    Replies: 7
    Last Post: 01-25-2009, 07:33 AM
  2. exception handling
    By coletek in forum C++ Programming
    Replies: 2
    Last Post: 01-12-2009, 05:28 PM
  3. Handle C++ exception and structured exception together
    By George2 in forum C++ Programming
    Replies: 2
    Last Post: 01-24-2008, 09:21 PM
  4. Stack overflow errors in 3 areas
    By ulillillia in forum C Programming
    Replies: 13
    Last Post: 04-29-2007, 03:20 PM
  5. Problem with the exception class in MINGW
    By indigo0086 in forum C++ Programming
    Replies: 6
    Last Post: 01-20-2007, 01:12 PM