I've got a simple VB.NET project which has been running great for over a year now. The boss came to me and asked for some changes to it. The main one being that the project now looks for a text file to get a bunch of configuration defaults before running. Okay cool, so I run the project from VS in debug and it works perfect. Now the boss wants to see it in action so I copy the stand-alone exe file over to the server and he runs it but we get an error message. See the attached snippet shot.
So I look into the details and it tells me that the error occurred at line #239 of my project which is the line shown in red in this code:
I went back and tested this at my computer and sure enough it produces the same error. BUT ... I can run the project inside of VS and it works just fine. I don't know where to turn on this one because I have never seen a project work in VS and then not work when I run just the exe. Just in case this is needed, here is the Exception Text section of the details:Code:Private Sub GetDefaults() Dim vFile As String = "\\a_long_novell_path\CONFIG.txt" If File.Exists(vFile) Then Dim vDefaults() As String = File.ReadAllLines(vFile) Dim s As String For Each s In vDefaults If s.Substring(0, 1) <> "#" Then If s.Contains("EngSvrPath") Then vdbname = s.Substring(s.IndexOf("=") + 2) & "Engineering\Databases\DwgChkList.mdb" End If If s.Contains("CheckListTop") Then lblTopText.Text = s.Substring(s.IndexOf("=") + 2) End If If s.Contains("CheckListBot") Then lblBottomText.Text = s.Substring(s.IndexOf("=") + 2) End If End If Next Else MsgBox("Oops! The configuration file is missing" & vbCrLf & "Please contact administrator for assistance", MsgBoxStyle.OkOnly) Windows.Forms.Application.Exit() End If End Sub
************** Exception Text **************
System.ArgumentOutOfRangeException: Index and length must refer to a location within the string.
Parameter name: length
at System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy)
at WindowsApplication1.Form1.GetDefaults() in C:\Engineering\Eng Utilities\DwgCheckList(01)\DwgCheckList(01)\Form1.vb:line 239
at WindowsApplication1.Form1.Form1_Load(Object sender, EventArgs e) in C:\Engineering\Eng Utilities\DwgCheckList(01)\DwgCheckList(01)\Form1.vb:line 69
at System.EventHandler.Invoke(Object sender, EventArgs e)
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.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)