Click here to Skip to main content
15,890,690 members
Home / Discussions / C#
   

C#

 
AnswerRe: treeview question? Pin
PIEBALDconsult9-Nov-09 15:35
mvePIEBALDconsult9-Nov-09 15:35 
QuestionHow to design? [modified] Pin
konglx sir9-Nov-09 14:47
konglx sir9-Nov-09 14:47 
AnswerRe: How to design? Pin
Christian Graus9-Nov-09 15:23
protectorChristian Graus9-Nov-09 15:23 
AnswerRe: How to design? Pin
PIEBALDconsult9-Nov-09 15:37
mvePIEBALDconsult9-Nov-09 15:37 
QuestionHow to call List[int] in other class [modified] Pin
laurisp9-Nov-09 13:57
laurisp9-Nov-09 13:57 
AnswerRe: How to call List[int] in other class Pin
Julianne_juju9-Nov-09 19:19
Julianne_juju9-Nov-09 19:19 
GeneralRe: How to call List[int] in other class Pin
laurisp9-Nov-09 21:29
laurisp9-Nov-09 21:29 
Questionnullrefererence exception Pin
hobbsjas9-Nov-09 13:31
hobbsjas9-Nov-09 13:31 
Here is a block of code that copies a file:

private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            string[] src = e.Argument as string[];
            cnt = 0;
            while (cnt < src.Length && src[cnt] != null)
            {
                toolStripStatusLabel1.Text = "Copying " + src[cnt] + "...";
                string[] words = src[cnt].Split('\\');
                string dest = keeppath2 + "\\" + words[words.Length - 1];
                if (dest.IndexOf(".") > -1)
                {
                    FileStream inFile = new FileStream(src[cnt].ToString(), System.IO.FileMode.Open);
                    if (!System.IO.File.Exists(dest))
                    {
                        using (System.IO.FileStream fs = System.IO.File.Create(dest))
                        {
                            for (byte i = 0; i < 100; i++)
                            {
                                fs.WriteByte(i);
                            }
                        }
                    }
                    FileStream outFile = new FileStream(dest, System.IO.FileMode.Open);
                    long size = inFile.Length;
                    int lineSize = 1024 * 64;
                    long filesize1 = inFile.Position / 1024;
                    long filesize2 = inFile.Length / 1024;
                    byte[] buffer = new byte[lineSize];
                    while ((inFile.Read(buffer, 0, lineSize)) > 0)
                    {
                        outFile.Write(buffer, 0, lineSize);
                        filesize1 = inFile.Position / 1024;
                        toolStripStatusLabel1.Text = "Copying " + src[cnt] + "... " + filesize1 + "KB of " + filesize2 + "KB";
                    }
                    outFile.Flush();
                    outFile.Close();
                    inFile.Flush();
                    inFile.Close();
                }
                else
                {
                    try
                    {
                        copyDirectory(src[cnt].ToString(), dest, toolStripStatusLabel1);
                    }
                    catch (Exception error)
                    {
                        //toolStripStatusLabel1.Text = error.Message.ToString();
                    }
                }
                cnt++;
            }
        }


Every once in a while I get this error when copying:
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 System.Windows.Forms.ToolStripItem.get_ContentRectangle()
   at System.Windows.Forms.ToolStripSystemRenderer.RenderLabelInternal(ToolStripItemRenderEventArgs e)
   at System.Windows.Forms.ToolStripSystemRenderer.OnRenderToolStripStatusLabelBackground(ToolStripItemRenderEventArgs e)
   at System.Windows.Forms.ToolStripRenderer.DrawToolStripStatusLabelBackground(ToolStripItemRenderEventArgs e)
   at System.Windows.Forms.ToolStripStatusLabel.OnPaint(PaintEventArgs e)
   at System.Windows.Forms.ToolStripItem.HandlePaint(PaintEventArgs e)
   at System.Windows.Forms.ToolStrip.OnPaint(PaintEventArgs e)
   at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs)
   at System.Windows.Forms.Control.WmPaint(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ToolStrip.WndProc(Message& m)
   at System.Windows.Forms.StatusStrip.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
    CodeBase: file:///C:/Windows/Microsoft.NET/Framework64/v2.0.50727/mscorlib.dll
----------------------------------------
Filemon
    Assembly Version: 1.0.0.0
    Win32 Version: 1.0.0.0
    CodeBase: file:///C:/Users/Grimmstede/AppData/Local/Apps/2.0/GZ0XOYX1.QBL/HKQL7318.DOJ/file..tion_72d0129a53d9859f_0001.0000_fd31371f1e135068/Filemon.exe
----------------------------------------
System.Windows.Forms
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------

************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
    <system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.


Does anyone know how to avoid this error?

I will also occasionally get this error:

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

************** Exception Text **************
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
   at System.Collections.ArrayList.get_Item(Int32 index)
   at System.Windows.Forms.ToolStripItemCollection.get_Item(Int32 index)
   at System.Windows.Forms.ToolStrip.OnPaint(PaintEventArgs e)
   at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs)
   at System.Windows.Forms.Control.WmPaint(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ToolStrip.WndProc(Message& m)
   at System.Windows.Forms.StatusStrip.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
    CodeBase: file:///C:/Windows/Microsoft.NET/Framework64/v2.0.50727/mscorlib.dll
----------------------------------------
Filemon
    Assembly Version: 1.0.0.0
    Win32 Version: 1.0.0.0
    CodeBase: file:///C:/Users/Grimmstede/AppData/Local/Apps/2.0/GZ0XOYX1.QBL/HKQL7318.DOJ/file..tion_72d0129a53d9859f_0001.0000_fd31371f1e135068/Filemon.exe
----------------------------------------
System.Windows.Forms
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------

************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
    <system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.


Thanks for looking
AnswerRe: nullrefererence exception Pin
Luc Pattyn9-Nov-09 14:33
sitebuilderLuc Pattyn9-Nov-09 14:33 
GeneralRe: nullrefererence exception Pin
hobbsjas9-Nov-09 15:26
hobbsjas9-Nov-09 15:26 
GeneralRe: nullrefererence exception Pin
Luc Pattyn9-Nov-09 15:31
sitebuilderLuc Pattyn9-Nov-09 15:31 
GeneralRe: nullrefererence exception Pin
hobbsjas9-Nov-09 15:53
hobbsjas9-Nov-09 15:53 
GeneralRe: nullrefererence exception Pin
N a v a n e e t h9-Nov-09 16:02
N a v a n e e t h9-Nov-09 16:02 
GeneralRe: nullrefererence exception Pin
Luc Pattyn9-Nov-09 16:05
sitebuilderLuc Pattyn9-Nov-09 16:05 
GeneralRe: nullrefererence exception Pin
N a v a n e e t h9-Nov-09 15:59
N a v a n e e t h9-Nov-09 15:59 
GeneralRe: nullrefererence exception Pin
hobbsjas10-Nov-09 9:25
hobbsjas10-Nov-09 9:25 
QuestionInconsistent accessibility: property type is less accessible than property Pin
Kevin Marois9-Nov-09 13:28
professionalKevin Marois9-Nov-09 13:28 
AnswerRe: Inconsistent accessibility: property type is less accessible than property Pin
J$9-Nov-09 13:36
J$9-Nov-09 13:36 
GeneralRe: Inconsistent accessibility: property type is less accessible than property Pin
Kevin Marois9-Nov-09 13:49
professionalKevin Marois9-Nov-09 13:49 
GeneralRe: Inconsistent accessibility: property type is less accessible than property Pin
Luc Pattyn9-Nov-09 13:56
sitebuilderLuc Pattyn9-Nov-09 13:56 
QuestionWin32 Message Hooks and/or Legitimate Code Injection Pin
cymblicity9-Nov-09 12:54
cymblicity9-Nov-09 12:54 
AnswerRe: Win32 Message Hooks and/or Legitimate Code Injection Pin
Luc Pattyn9-Nov-09 15:28
sitebuilderLuc Pattyn9-Nov-09 15:28 
Questionhow can i calculate shortest path between neurons in artifical neural network graph? Pin
karayel_kara9-Nov-09 12:32
karayel_kara9-Nov-09 12:32 
QuestionC# subject not correct form because of shift+enter Pin
Jacob Dixon9-Nov-09 10:45
Jacob Dixon9-Nov-09 10:45 
AnswerRe: C# subject not correct form because of shift+enter Pin
Abhishek Sur9-Nov-09 10:48
professionalAbhishek Sur9-Nov-09 10:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.