views:

34

answers:

1

I have a .Net 2 solution with some asp classic pages.

I get a specified cast is not valid error when I access the page on my local. Below is the vb function where I get the Error:

    Public Function Retrieve(ByVal vntSeqId As String, ByRef vntPart As String, ByRef vntPartKey As String, ByRef vntEntDate As String _
    , ByRef vntStatus As String, ByRef vntOrigGblId As String, ByRef vntOrigNetId As String, ByRef vntOrigName As String, ByRef vntOrigPhone As String _
    , ByRef vntOrigMs As String, ByRef vntReqType As String, ByRef vntPriority As String, ByRef vntAudBldg As String, ByRef vntRemarks As String _
    , ByRef vntMbldg As String, ByRef vntTlStk As String, ByRef vntTlDef As String, ByRef vntTlAud As String, ByRef vntOrdPend As String _
    , ByRef vntAction As String, ByRef vntCompGblId As String, ByRef vntCompNetId As String, ByRef vntCompName As String, ByRef vntCompPhone As String _
    , ByRef vntCompMs As String, ByRef vntActTk As String, ByRef vntComp As String, ByRef vntCompDate As String, ByRef vntOffHold As String _
    , ByRef vntQtyShp As String, ByRef vntShpDt As String, ByRef vntCartons As String, ByRef vntComments As String, ByRef vntRowlock As String _
    , ByRef vntOnHoldDt As String, ByRef vntOnHoldGblId As String, ByRef vntOffHoldDt As String, ByRef vntOffHoldGblId As String, ByRef vntOnHoldName As String _
    , ByRef vntOffHoldName As String, ByRef vntStatDesc As String, ByRef vntReqTypeDesc As String, ByRef vntPriorDesc As String, ByRef vntAudBldgDesc As String _
    , ByRef vntActionDesc As String, ByRef vntActTkDesc As String, ByRef vntDateCde As String, ByRef strSamplingPlan As String, ByRef vntFO As String _
    , ByRef vntPO As String, ByRef vntIblId As String, ByRef vntOnHoldNetId As String, ByRef vntOffHoldNetId As String, ByRef vntOrigEmail As String _
    , ByRef vntCompEmail As String, ByRef vntTlHold As String, ByRef vntImportAuditInd As String _
    , ByRef vntErrorNumber As Integer, ByRef vntErrorDesc As String) As Boolean


        On Error GoTo ErrorHandler

        Dim blnRC As Boolean
        Dim vntTemp As String = String.Empty
        Dim intCount As Integer
        Dim vntPrcntPcs As String
        Dim vntSampPlan As String

        If vntSeqId = "" Then
            Err.Raise(267, , "Sequence ID not specified")
        End If

        Dim objCallSP As New clsCallSP
        blnRC = objCallSP.CallSP("QneEngAudit.RetrieveAudit", vntErrorNumber, vntErrorDesc _
            , "I", vntSeqId _
            , "O", vntPart, "O", vntPartKey, "O", vntEntDate, "O", vntStatus, "O", vntOrigGblId, "O", vntOrigNetId, "O", vntReqType _
            , "O", vntPriority, "O", vntAudBldg, "OL", vntRemarks, "O", vntMbldg, "O", vntTlStk, "O", vntTlDef, "O", vntTlAud, "O", vntOrdPend _
            , "O", vntAction, "O", vntCompGblId, "O", vntActTk, "O", vntComp, "O", vntCompDate, "O", vntOffHold, "O", vntQtyShp, "O", vntShpDt _
            , "O", vntCartons, "OL", vntComments, "O", vntRowlock, "O", vntOnHoldDt, "O", vntOnHoldGblId, "O", vntOffHoldDt _
            , "O", vntOffHoldGblId, "O", vntImportAuditInd)
        If Not (blnRC AndAlso vntErrorNumber = 0) Then
            Err.Raise(vntErrorNumber, , vntErrorDesc)
        End If

        vntPart = objCallSP.OutParams(0)
        vntPartKey = objCallSP.OutParams(1)
        vntEntDate = objCallSP.OutParams(2)
        vntStatus = objCallSP.OutParams(3)
        vntOrigGblId = objCallSP.OutParams(4)
        vntOrigNetId = objCallSP.OutParams(5)
        vntReqType = objCallSP.OutParams(6)
        vntPriority = objCallSP.OutParams(7)
        vntAudBldg = objCallSP.OutParams(8)
        vntRemarks = objCallSP.OutParams(9)
        vntMbldg = objCallSP.OutParams(10)
        vntTlStk = objCallSP.OutParams(11)
        vntTlDef = objCallSP.OutParams(12)
        vntTlAud = objCallSP.OutParams(13)
        vntOrdPend = objCallSP.OutParams(14)
        vntAction = objCallSP.OutParams(15)
        vntCompGblId = objCallSP.OutParams(16)
        vntActTk = objCallSP.OutParams(17)
        vntComp = objCallSP.OutParams(18)
        vntCompDate = objCallSP.OutParams(19)
        vntOffHold = objCallSP.OutParams(20)
        vntQtyShp = objCallSP.OutParams(21)
        vntShpDt = objCallSP.OutParams(22)
        vntCartons = objCallSP.OutParams(23)
        vntComments = objCallSP.OutParams(24)
        vntRowlock = objCallSP.OutParams(25)
        vntOnHoldDt = objCallSP.OutParams(26)
        vntOnHoldGblId = objCallSP.OutParams(27)
        vntOffHoldDt = objCallSP.OutParams(28)
        vntOffHoldGblId = objCallSP.OutParams(29)
        vntImportAuditInd = objCallSP.OutParams(30)

        If vntPart = "" OrElse vntPartKey = "" Then
            Err.Raise(281, , "Part number or part key ID not found for specified sequence ID")
        End If

        If vntOrigGblId <> "" Then
            blnRC = (New clsAssociate).RetrieveByGblId(vntOrigGblId, vntOrigName, vntOrigNetId, vntOrigEmail, vntOrigPhone, vntOrigMs, vntTemp, vntTemp, vntErrorNumber, vntErrorDesc)
        End If

        If vntOrigGblId = "" AndAlso vntOrigNetId <> "" Then
            blnRC = (New clsAssociate).RetrieveByNetId(vntOrigNetId, vntOrigName, vntOrigGblId, vntOrigEmail, vntOrigPhone, vntOrigMs, vntTemp, vntTemp, vntErrorNumber, vntErrorDesc)
        End If

        If vntStatus <> "" Then
            blnRC = (New clsStatus).Retrieve(vntStatus, vntTemp, vntStatDesc, vntErrorNumber, vntErrorDesc)
            If vntErrorNumber <> 0 Then
                Err.Raise(vntErrorNumber, , vntErrorDesc)
            End If
        End If

        If vntAudBldg <> "" Then
            blnRC = (New clsGlobalData).Retrieve(vntAudBldg, vntTemp, vntTemp, vntTemp, vntTemp, vntAudBldgDesc, vntTemp, vntTemp, vntErrorNumber, vntErrorDesc)
            If vntErrorNumber <> 0 Then
                Err.Raise(vntErrorNumber, , vntErrorDesc)
            End If
        End If

        If vntCompGblId <> "" Then
            blnRC = (New clsAssociate).RetrieveByGblId(vntCompGblId, vntCompName, vntCompNetId, vntCompEmail, vntCompPhone, vntCompMs, vntTemp, vntTemp, vntErrorNumber, vntErrorDesc)
        End If

        If vntOnHoldGblId <> "" Then
            blnRC = (New clsAssociate).RetrieveByGblId(vntOnHoldGblId, vntOnHoldName, vntOnHoldNetId, vntTemp, vntTemp, vntTemp, vntTemp, vntTemp, vntErrorNumber, vntErrorDesc)
        End If

        If vntOffHoldGblId <> "" Then
            blnRC = (New clsAssociate).RetrieveByGblId(vntOffHoldGblId, vntOffHoldName, vntOffHoldNetId, vntTemp, vntTemp, vntTemp, vntTemp, vntTemp, vntErrorNumber, vntErrorDesc)
        End If

        If vntAction <> "" Then
            blnRC = (New clsDisposition).RetrieveCategory(vntAction, vntActionDesc, vntErrorNumber, vntErrorDesc)
            If vntErrorNumber <> 0 Then
                Err.Raise(vntErrorNumber, , vntErrorDesc)
            End If
        End If

        If vntReqType <> "" Then
            blnRC = (New clsRequestType).Retrieve(vntReqType, vntReqTypeDesc, vntErrorNumber, vntErrorDesc)
            If vntErrorNumber <> 0 Then
                Err.Raise(vntErrorNumber, , vntErrorDesc)
            End If
        End If

        If vntPriority <> "" Then
            blnRC = (New clsPriority).Retrieve(vntPriority, vntPriorDesc, vntErrorNumber, vntErrorDesc)
            If vntErrorNumber <> 0 Then
                Err.Raise(vntErrorNumber, , vntErrorDesc)
            End If
        End If

        If vntActTk <> "" Then
            blnRC = (New clsAuditType).Retrieve(vntActTk, vntTemp, vntActTkDesc, vntErrorNumber, vntErrorDesc)
            If vntErrorNumber <> 0 Then
                Err.Raise(vntErrorNumber, , vntErrorDesc)
            End If
        End If

        Dim vntArray As Object(,) = (New clsAddFields).List(vntSeqId, vntErrorNumber, vntErrorDesc)
        If Not IsNothing(vntArray) Then
            vntSampPlan = ""
            vntPrcntPcs = ""
            vntDateCde = ""
            vntFO = ""
            vntPO = ""
            vntIblId = ""
            vntTlHold = ""
            For intCount = 0 To UBound(vntArray, 2)
                Select Case CInt(vntArray(0, intCount))
                    Case 1
                        If vntDateCde = "" Then
                            vntDateCde = Trim(vntArray(1, intCount).ToString())
                        Else
                            vntDateCde &= "," & Trim(vntArray(1, intCount).ToString())
                        End If
                    Case 2
                        If vntFO = "" Then
                            vntFO = Trim(vntArray(1, intCount).ToString())
                        Else
                            vntFO &= "," & Trim(vntArray(1, intCount).ToString())
                        End If
                    Case 3
                        If vntPO = "" Then
                            vntPO = Trim(vntArray(1, intCount).ToString())
                        Else
                            vntPO &= "," & vntArray(1, intCount).ToString()
                        End If
                    Case 5
                        If vntIblId = "" Then
                            vntIblId = Trim(vntArray(1, intCount).ToString())
                        Else
                            vntIblId &= "," & Trim(vntArray(1, intCount).ToString())
                        End If
                    Case 7
                        If vntTlHold = "" Then
                            vntTlHold = Trim(vntArray(1, intCount).ToString())
                        Else
                            vntTlHold &= "," & Trim(vntArray(1, intCount).ToString())
                        End If
                    Case 8
                        If vntSampPlan = "" Then
                            vntSampPlan = Trim(vntArray(1, intCount).ToString())
                        Else
                            vntSampPlan &= "," & Trim(vntArray(1, intCount).ToString())
                        End If
                    Case 9
                        If vntPrcntPcs = "" Then
                            vntPrcntPcs = Trim(vntArray(1, intCount).ToString())
                        Else
                            vntPrcntPcs &= "," & Trim(vntArray(1, intCount).ToString())
                        End If

                        'Case 10 'Audit Conversation Complete in WCS
                        '    Dim vntAuditConversationCompleteInWCS As String
                        '    vntAuditConversationCompleteInWCS = Trim(vntArray(1, intCount).ToString())
                End Select
            Next
            If vntSampPlan <> "" Then
                strSamplingPlan = vntSampPlan & "," & vntPrcntPcs
            End If
        Else
            vntDateCde = ""
            vntFO = ""
            vntPO = ""
            vntIblId = ""
            vntTlHold = ""
            vntSampPlan = ""
            'vntAuditConversationCompleteInWCS = ""
        End If

        vntErrorNumber = 0
        vntErrorDesc = ""

        Return True

ErrorHandler:

        vntErrorNumber = Err.Number
        vntErrorDesc = String.Format("{0} ({1})", Err.Description, Utility.QualifiedMethodName())

        Return False

    End Function

At first, I thought the problem is with the source code and we were thinking the source code we have is different with the ones deployed on test and prod servers. But when I tried to upload it on the test server, I don't get the specified cast is not valid error.

Any ideas what to check with the setup or configs? registered assemblies maybe?

+1  A: 

It may be data related. Do all environments use the same data source?

BTW, don't you have the required environment for debugging to find the problem?

Edit After Comments

Then try to debug it by old style asp debugging technique.

Add a code like Err.Raise(0, , "Code running to here without any problem"). If you get the cast error rather than this one then you have problem with the codes before it :)

At least it helps you to find the code causes the error.

orka
development and test server are using the same test db
Emirage
are the config files the same? It may be a wrong data in the config file which is tried to cast. (such as a string value rather than integer for an application setting in the web config file)
orka
yeah, i don't.. sort of.. I have visual studio but since the page being accessed are asp pages, I almost can't debug... not everything. When I attached the process, I can debug the asp files but not the vb classes being called.
Emirage
I also tried to make a similar web.config file on my local, but still the same
Emirage
Have you ever tried to attach both DllHost.exe and w3wp.exe (or aspnet worker process in the older windows OS) to be able to debug both? I am not sure but i think it may work. Just look at [this thread](http://stackoverflow.com/questions/730229/step-through-debugging-for-classic-asp-with-vs2008) for debugging classic asp with VS2008.
orka
unfortunately, I have some license issues for installing vs2008 in the office. I'll have to stick with vs2005 for now. Anyway, thanks for the advise orka. My project coordinator and I are really hating this current project.
Emirage
I understand your difficulties. How about checking [VS2005 ASP Debugging](http://stackoverflow.com/questions/958968/has-anybody-been-able-to-debug-asp-classic-code-with-visual-studio-2005-or-later) thread. Hope it helps.
orka