I'm trying to fill an array of objects but when I add the first object I get
a NullReferenceEx ception.
----------------------------------------------------------------------------
-------------------------------------------
Public Class TestClass
Public NextSubIndex As Integer = 1
Public arrTestSubClass () As TestSubClass
Public tmpHold As TestSubClass
Sub AddSub(ByVal Name As String)
tmpHold = New TestSubClass(Na me)
Me.arrTestSubCl ass(NextSubInde x) = tmpHold <<<<Error Here>>>
NextSubIndex = NextSubIndex + 1
End Sub
End Class
----------------------------------------------------------------------------
------------------------------------------
Can someone tell me why I'm getting the NullReferenceEx ception when this
code executes? Stack Trace and more below.
Thank You!
Scott
Exception Details: System.NullRefe renceException: Object reference not set
to an instance of an object.
Source Error:
Line 68:
Line 69: Private Sub btnAddSub_Click (ByVal sender As System.Object,
ByVal e As System.EventArg s) Handles btnAddSub.Click
Line 70: Session("MyTest Class").AddSub( TextBox2.Text)
Line 71: End Sub
Line 72:
Source File: c:\inetpub\wwwr oot\ASPTests\Te stClassClient.a spx.vb Line: 70
Stack Trace:
[NullReferenceEx ception: Object reference not set to an instance of an
object.]
Microsoft.Visua lBasic.Compiler Services.LateBi nding.InternalL ateCall(Object
o, Type objType, String name, Object[] args, String[] paramnames, Boolean[]
CopyBack, Boolean IgnoreReturn)
Microsoft.Visua lBasic.Compiler Services.LateBi nding.LateCall( Object o,
Type objType, String name, Object[] args, String[] paramnames, Boolean[]
CopyBack)
ASPTests.TestCl assClient.btnAd dSub_Click(Obje ct sender, EventArgs e) in
c:\inetpub\wwwr oot\ASPTests\Te stClassClient.a spx.vb:70
System.Web.UI.W ebControls.Butt on.OnClick(Even tArgs e)
System.Web.UI.W ebControls.Butt on.System.Web.U I.IPostBackEven tHandler.RaiseP o
stBackEvent(Str ing eventArgument)
System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler
sourceControl, String eventArgument)
System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData)
System.Web.UI.P age.ProcessRequ estMain()
a NullReferenceEx ception.
----------------------------------------------------------------------------
-------------------------------------------
Public Class TestClass
Public NextSubIndex As Integer = 1
Public arrTestSubClass () As TestSubClass
Public tmpHold As TestSubClass
Sub AddSub(ByVal Name As String)
tmpHold = New TestSubClass(Na me)
Me.arrTestSubCl ass(NextSubInde x) = tmpHold <<<<Error Here>>>
NextSubIndex = NextSubIndex + 1
End Sub
End Class
----------------------------------------------------------------------------
------------------------------------------
Can someone tell me why I'm getting the NullReferenceEx ception when this
code executes? Stack Trace and more below.
Thank You!
Scott
Exception Details: System.NullRefe renceException: Object reference not set
to an instance of an object.
Source Error:
Line 68:
Line 69: Private Sub btnAddSub_Click (ByVal sender As System.Object,
ByVal e As System.EventArg s) Handles btnAddSub.Click
Line 70: Session("MyTest Class").AddSub( TextBox2.Text)
Line 71: End Sub
Line 72:
Source File: c:\inetpub\wwwr oot\ASPTests\Te stClassClient.a spx.vb Line: 70
Stack Trace:
[NullReferenceEx ception: Object reference not set to an instance of an
object.]
Microsoft.Visua lBasic.Compiler Services.LateBi nding.InternalL ateCall(Object
o, Type objType, String name, Object[] args, String[] paramnames, Boolean[]
CopyBack, Boolean IgnoreReturn)
Microsoft.Visua lBasic.Compiler Services.LateBi nding.LateCall( Object o,
Type objType, String name, Object[] args, String[] paramnames, Boolean[]
CopyBack)
ASPTests.TestCl assClient.btnAd dSub_Click(Obje ct sender, EventArgs e) in
c:\inetpub\wwwr oot\ASPTests\Te stClassClient.a spx.vb:70
System.Web.UI.W ebControls.Butt on.OnClick(Even tArgs e)
System.Web.UI.W ebControls.Butt on.System.Web.U I.IPostBackEven tHandler.RaiseP o
stBackEvent(Str ing eventArgument)
System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler
sourceControl, String eventArgument)
System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData)
System.Web.UI.P age.ProcessRequ estMain()
Comment