1

用户随机收到“无法将“X”类型的对象转换为“X”类型的异常错误。有时这个问题一天会发生几次。有时我们可以去一个星期+没有它出现。

我有一个序列化对象(“X”),我在列表“CurrentDetails”和“NextDetails”中填充为“X”。在文本更改事件中,我检查“CurrentDetails”中的值,此时异常触发。“无法将 X 类型的对象转换为 X 类型”这里有一些代码示例......

文本更改事件(编辑以显示原始数据)

Protected Sub txtPackaging_TextChanged(sender As Object, e As System.EventArgs) Handles txtPackaging.TextChanged
    If WarehouseManager.GetDeliveryStatus(CurrentSUPPDelivery.DeliveryNumber) > 60 Then
        'GETTIGN ERROR HERE Unable to cast object of type 'SUPPDelivery' to type 'SUPPDelivery' 
        'THROW ERROR
        SetErrorMessage("<b>REFRESH/BACK DETECTED!</b> <br/> Or, this item has already been packed. <br/> Please exit wave.")
        pnlItemDetails.Visible = False
        pnlCurrent.Visible = False
        pnlWaveDetails.Visible = False
    Else 'continue pick/pack
        btnProcessSingleItem_Click(sender, e)

    End If

End Sub

查看状态对象(编辑以显示原始数据)

Private Property CurrentSUPPDelivery() As WarehouseManager.SUPPDelivery
    Get
        Return Me.ViewState("CurrentSUPPDelivery")
    End Get
    Set(ByVal value As WarehouseManager.SUPPDelivery)
        Me.ViewState("CurrentSUPPDelivery") = value
    End Set
End Property

它在 txtChange 事件的 IF 语句上引发错误。有任何想法吗?

编辑:原始堆栈数据....

堆栈跟踪:在 C:\Inetpub\lawsonwebapps\warehouse\mobile\SingleUnitPickPack.aspx.vb 中的 Warehouse_SingleUnitPickPack.get_CurrentSUPPDelivery():C:\Inetpub\lawsonwebapps\warehouse\ 中 Warehouse_SingleUnitPickPack.txtPackaging_TextChanged(Object sender, EventArgs e) 的第 107 行mobile\SingleUnitPickPack.aspx.vb:System.Web.UI.WebControls.TextBox.OnTextChanged(EventArgs e) 的 System.Web.UI.WebControls.TextBox.RaisePostDataChangedEvent() 的 System.Web.UI.WebControls.TextBox 的第 249 行.System.Web.UI.IPostBackDataHandler.RaisePostDataChangedEvent() 在 System.Web.UI.Page.RaiseChangedEvents() 在 System.Web.UI.Page.ProcessRequestMain(布尔值 includeStagesBeforeAsyncPoint,布尔值 includeStagesAfterAsyncPoint)

编辑:“X” - Manager.CurrentDetails ... RAW 名称:SUPPDelivery

<Serializable()> Public Class SUPPDelivery

        Private _DeliveryNumber As String
        Private _OrderNumber As String
        Private _OrderLine As String
        Private _TransactionType As String
        Private _PackedQty As String
        Private _PackageNumber As String
        Private _PackageMaterial As String
        Private _OrderLineSuffix As String
        Private _ItemNumber As String
        Private _ItemLocation As String

        Public Property DeliveryNumber() As String
            Get
                Return _DeliveryNumber
            End Get
            Set(ByVal value As String)
                _DeliveryNumber = value
            End Set
        End Property

        Public Property OrderNumber() As String
            Get
                Return _OrderNumber
            End Get
            Set(ByVal value As String)
                _OrderNumber = value
            End Set
        End Property

        Public Property OrderLine() As String
            Get
                Return _OrderLine
            End Get
            Set(ByVal value As String)
                _OrderLine = value
            End Set
        End Property

        Public Property TransactionType() As String
            Get
                Return _TransactionType
            End Get
            Set(ByVal value As String)
                _TransactionType = value
            End Set
        End Property

        Public Property PackedQty() As String
            Get
                Return _PackedQty
            End Get
            Set(ByVal value As String)
                _PackedQty = value
            End Set
        End Property

        Public Property PackageNumber() As String
            Get
                Return _PackageNumber
            End Get
            Set(ByVal value As String)
                _PackageNumber = value
            End Set
        End Property

        Public Property PackageMaterial() As String
            Get
                Return _PackageMaterial
            End Get
            Set(ByVal value As String)
                _PackageMaterial = value
            End Set
        End Property

        Public Property OrderLineSuffix() As String
            Get
                Return _OrderLineSuffix
            End Get
            Set(ByVal value As String)
                _OrderLineSuffix = value
            End Set
        End Property

        Public Property ItemNumber() As String
            Get
                Return _ItemNumber
            End Get
            Set(ByVal value As String)
                _ItemNumber = value
            End Set
        End Property

        Public Property ItemLocation() As String
            Get
                Return _ItemLocation
            End Get
            Set(ByVal value As String)
                _ItemLocation = value
            End Set
        End Property

    End Class
4

0 回答 0