Home All Groups Group Topic Archive Search About

Object loses pointer to Base class

Author
6 Dec 2006 11:20 PM
Wicks
Wiered bug - it's as if the whole virtual function table goes missing

    It's a page with many private variables holding pointers to object
collections with nested object collections.

Object Inheritance chain in this instance is
System.Web.Ui.Page
|-----> ShippingPage
         |--------> _Shipment    (Codebehind class of aspx page)

Page has a master page as well whose inheritance is
System.Web.UI.MasterPage
|-----> ShippingMaster    (Codebehind class of master page)


The following code snippet breaks everything in a wiered way

Before the following line of code everything is fine

ctl_LottingLotLength.New_Enabled = RecordSelected And
DetailShipment.Status_AllowEdit_Flag And (Not
MyBase.prop_isDataNewMode) And (Not
DetailLotLength.ParentLotLengthCollection.ParentLot.BaseLot.IsInvoiced)

When MyBase.prop_isDataNewMode is evaluated everything breaks and it
ends up throwing an "Object reference not set to an instance of an
object exception on MyBase itself

After this has hapenned the following all result in exceptions. It's as
if the whole virtual function table of the object has gone to hell.

MyBase.prop_isDataNewMode  =  Exception  "The pointer for this method
was null."
MyBase.IsPostBack                 =  Exception  "The pointer for this
method was null."
MyBase.Controls                     =  Exception   "Object cannot be
null."
Me.prop_isDataNewMode  =  Exception  "The pointer for this method was
null."
Me.IsPostBack                 =  Exception  "The pointer for this
method was null."
Me.Controls                     =  Exception   "Object cannot be null."
prop_isDataNewMode  =  Exception  "The pointer for this method was
null."
IsPostBack                 =  Exception  "The pointer for this method
was null."
Controls                     =  Exception   "Object cannot be null."

prop_isDataNewMode itself is a simple viewstate persisted boolean
property
Code follows:

Public Property prop_isDataNewMode() As Boolean
    Get
        Dim obj As Object
        obj = ViewState.Item("ShippingPage_prop_isDataNewMode")
        If obj Is Nothing Then
            Return False
        Else
            Return CType(obj, Boolean)
        End If
    End Get
    Set(ByVal value As Boolean)
        ViewState.Add("ShippingPage_prop_isDataNewMode", value)
    End Set
End Property



The workaround is just as wiered. When I replace the code segment with
the following logically identical code segment it works fine.

'-- This works fine
ctl_LottingLotLength.New_Enabled = False
If RecordSelected Then
    If DetailShipment.Status_AllowEdit_Flag Then
        If Not MyBase.prop_isDataNewMode Then
            If Not
DetailLotLength.ParentLotLengthCollection.ParentLot.BaseLot.IsInvoiced
Then
                ctl_LottingLotLength.New_Enabled = True
            End If
        End If
    End If
End If


which although a bit retarded is functionally identical to the problem
child below.

'-- This does not work
ctl_LottingLotLength.New_Enabled = RecordSelected And
DetailShipment.Status_AllowEdit_Flag And (Not
MyBase.prop_isDataNewMode) And (Not
DetailLotLength.ParentLotLengthCollection.ParentLot.BaseLot.IsInvoiced)


Anyone have any idea what's hapenning here ?

AddThis Social Bookmark Button