[RESOLVED] Unexpected Error
Ok i made a program it worked fine. I changed Net Framework to 3.5, then back to version 4 (i was testing something)
It now works fine.
I run the program from vb.net in debug mode and everythign works fine.
I clean the build,
I then build the project.
I then run the built exe but then it shows an error. The error point to this code:
Code:
Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles Me.Load
If Not My.Computer.FileSystem.DirectoryExists(wdir) Then
My.Computer.FileSystem.CreateDirectory(wdir)
End If
If Not My.Settings.prevsearch Is Nothing Then
If My.Settings.prevsearch <> "" Then
txt_g_url.Text = My.Settings.prevsearch
MsgBox(wdir)
End If
End If
For Each item As String In My.Settings.prevurl
If Not txturl.Items.Contains(item) Then
txturl.Items.Add(item)
End If
Next
End Sub
I cant figure out why this is. The main point is it works in debug but not after its built.
heres the exception error:
Code:
************** Exception Text **************
System.NullReferenceException: Object reference not set to an instance of an object.
at RAF_WEB.Form1.Form1_Load(Object sender, EventArgs e) in H:\Files\VB NET\Projects\RAF_WEB\RAF_WEB\Form1.vb:line 2311
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.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)
Re: [RESOLVED] Unexpected Error
I'm not familiar with the My.Settings but can';t you do one check at the beginning of the program and if it's empty instantiate it to an empty collection?
Something like:
vb Code:
If My.Settings is nothing Then
My.Settings = New SomeCollection(of SomeType)
End If
Re: [RESOLVED] Unexpected Error
Quote:
Originally Posted by
nycdev
I'm not familiar with the My.Settings but can';t you do one check at the beginning of the program and if it's empty instantiate it to an empty collection?
Something like:
vb Code:
If My.Settings is nothing Then
My.Settings = New SomeCollection(of SomeType)
End If
thats what i normally do