By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,837 Members | 1,667 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,837 IT Pros & Developers. It's quick & easy.

A first chance exception of type 'System.NullReferenceException' occurred in myapp.exe

P: n/a
GS
why am i getting
A first chance exception of type 'System.NullReferenceException' occurred in
myapp.exe

below? and what can i do get rid of it?

Private Function getPrefxType() As String
If bSkipGetListBOxComboBoxValue Then Return ""

Try
getPrefxType = DropListPreFxType.SelectedValue.ToString '
<<error
' the above line gives
'A first chance exception of type
'System.NullReferenceException' occurred in myapp.exe
Me.setStatus("OK")
Catch ex As Exception
If DropListPreFxType.SelectedIndex < 0 Then
DropListPreFxType.SelectedIndex = 0
'MsgBox("PrefxType ComboBox index=" &
DropListPreFxType.SelectedIndex.ToString & vbCrLf & "Text=" &
DropListPreFxType.Text & vbCrLf, MsgBoxStyle.Information, Me.Text & " -
@debug getPrefxType")
End If
getPrefxType = DropListPreFxType.Text.ToString()
End Try
getPrefxType = "Act" & getPrefxType
End Function
Jan 4 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Your code seems correct. You are using Try...Catch to test whether
DropListPreFxType.SelectedValue is Nothing. There's nothing wrong with
this, in my opinion.

See http://www.helixoft.com/blog/archives/24 for details how to disable
the message.

--
Peter Macej
Helixoft - http://www.helixoft.com
VSdocman - Commenter and generator of class documentation for C#, VB
..NET and ASP .NET code
Jan 4 '07 #2

P: n/a
GS wrote:
why am i getting
A first chance exception of type 'System.NullReferenceException' occurred in
myapp.exe below? and what can i do get rid of it?
Does the application continue to run or does it crash and burn?
Does this only happen in the IDE?

If the answers to the above are "continue" and "yes", then you've
probably asked the IDE to trap this Exception when you don't necessarily
want it to.

Menu: Debug Exceptions

System.NullReferenceException (wherever it appears in the /massive/ list
displayed) will be breaking into the debugger whenever it occurs - you
probably only care if it's not being handled in code.

HTH,
Phill W.
Jan 4 '07 #3

P: n/a
GS
thank you looking at the problem.
The application continues to run and seems to give result as expected.

Only when run in debug mod of IDE , do I see the msg in the Immediate
windows.
When run from windows directly, I do not see any msg nor any registry entry
in application related to this

"Phill W." <p-.-a-.-w-a-r-d@o-p-e-n-.-a-c-.-u-kwrote in message
news:en*********@south.jnrs.ja.net...
GS wrote:
why am i getting
A first chance exception of type 'System.NullReferenceException'
occurred in
myapp.exe below? and what can i do get rid of it?

Does the application continue to run or does it crash and burn?
Does this only happen in the IDE?

If the answers to the above are "continue" and "yes", then you've
probably asked the IDE to trap this Exception when you don't necessarily
want it to.

Menu: Debug Exceptions

System.NullReferenceException (wherever it appears in the /massive/ list
displayed) will be breaking into the debugger whenever it occurs - you
probably only care if it's not being handled in code.

HTH,
Phill W.

Jan 4 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Browse more Visual Basic .NET Questions on Bytes