Question : Diffrence between debug & release versions

Hello,

I have a following function.
When I run from debugger - it runs fine. But when I run from Released EXE file I get an exception.
Why? How can I avoid it.

THANK YOU
Margarit
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
void CopyFileToStr(string filestr)
        {
            try
            {
                FileStream HexFile = File.Open(filestr, FileMode.Open);
                StreamReader StreamReader_HexFile = new StreamReader(HexFile);
                HexFileString = StreamReader_HexFile.ReadToEnd();
                HexFile.Close();
                StreamReader_HexFile.Close();
            }
            catch
            {
                MessageBox.Show("Cannot copy file to string");
            }
        }


//Exception Details
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 RS232.fclsRS232Tester.btnClear_Click(Object sender, EventArgs e) in C:\RS232_Ver4\RS232\Form1.cs:line 252
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(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.1433 (REDBITS.050727-1400)
    CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
ControlBoardBoot
    Assembly Version: 1.0.0.0
    Win32 Version: 1.0.0.0
    CodeBase: file:///C:/RS232_Ver4/RS232/bin/Release/ControlBoardBoot.exe
----------------------------------------
System.Windows.Forms
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
    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.1433 (REDBITS.050727-1400)
    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.1433 (REDBITS.050727-1400)
    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.

Answer : Diffrence between debug & release versions

If the port on the switch is not up to par, sometimes that is just a physical issue.  Normally the contacts are just bent wire that is more or less spring loaded to make contact when the patch cable is pushed into the port.  In that case, sometimes a wire will get a little out of tollerance for some connectors.  When that happens, you can pull the wire up a little and see if that fixes it.  I have fixed a few switches and NICs in this manner only one of them ever had a problem again (it was a poorly constructed switch anyway).

If it is a smaller, less expensive switch, I would just replace it and cut your losses in labor.  If it is more expensive, you may consider putting some electricians tape accross the port so it can't be mistakenly used again. In a pinch I have seen this "repair" work for a couple switches that otherwise performed perfectly for a couple years.

- Tom

Random Solutions  
 
programming4us programming4us