none
Problem coping a List of (T) to another List of(T)

    Question

  • In short this downloads files from a Jason server. To do this I go out the the server and get a list of available files (The problem I am having is when try to copy Records in EPF_List_Query to Public lstDnLdFiles As New List(Of cFileInfo). I pass it the New files list in Public lstDnLdFiles As New List(Of cFileInfo). For some reason when I try to do the copy before the call to VerInfo.Download_Files() The program pops back up the query and highlights "File_info.File_Status = "N"" (no error just sits there).    

        Public blnStatusGood As Boolean = True
    
        Public LogWriter As System.IO.StreamWriter
        Public conString As String
    
        Public lstReturn As New List(Of cFileInfo)
        Public lstDnLdFiles As New List(Of cFileInfo)
        Public lstReports As New List(Of cFileInfo)
        Dim VerInfo As ClientCall = New ClientCall
    
        Sub Main()
    
            Dim strMsg As String = ""
            Dim retMsg As String = ""
    
            If RunMode = "T" Then
                strEmailRecipients = TestRecipients
                StartPath = TestPath
            Else
                strEmailRecipients = ProdRecipients
                StartPath = ProdPath
            End If
    
            ''*****************************************
            ''* Downloaded the Daily Files
            ''*****************************************
            Dim ReturnMsg As String = VerInfo.getVersion
            If Mid(ReturnMsg, 1, 7) <> "success" Then
                ReturnMsg = ReturnMsg & _
                " (Please Notify Programming, there is a connection error on the EPF server)"
                blnStatusGood = False
                GoTo Exit_Main
            End If
    
            strMsg = VerInfo.Retrieve_File_List
            Dim EPF_List_Query = From File_info In lstReturn Where (File_info.File_Status = "N") Select File_info
            If Mid(ReturnMsg, 1, 7) <> "success" Then
                ReturnMsg = ReturnMsg & _
                " (Please Notify Programming, Error in Retrieve File List)"
                blnStatusGood = False
                GoTo Exit_Main
            End If
            lstDnLdFiles.AddRange(EPF_List_Query)
            VerInfo.Download_Files("P")


    Tuesday, April 11, 2017 9:28 PM

Answers

  • Okay,

    I still see the LINQ statement, could use eliminate the LINQ statement and use a for/next or for/each.

    What if you only set File_Status in when populating the items, iterate now, does the code hang? If not, set another property and repeat until there is a hang in the code execution.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Wednesday, April 12, 2017 2:18 PM
    Moderator
  • I would first try to make the program in a way that the chance of errors are as low as possible. 

    It looks from the time of the first symbolic program languages like Algol and Fortran. Since Pascal it is not done anymore in this way.

    https://en.wikipedia.org/wiki/Goto


    Success
    Cor

    Wednesday, April 12, 2017 2:53 PM

All replies

  • Hi,

    Perhaps try a for/each on lstReturn, on each iteration see if File_Status = "N", if so then add it to the other list. Walk through the for/each, see if one of the items causes an issue.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Wednesday, April 12, 2017 12:33 PM
    Moderator
  • Ok I tried a For Next but get the same results when I try to access the EPF_List_Query even to just display the contents. I have looked at all 21 members they all good data. I get to the For next when I try to step into the code it locks highlighting (File_Info.FIle_Status = "N") but no message.

      


    Wednesday, April 12, 2017 1:57 PM
  • Okay,

    I still see the LINQ statement, could use eliminate the LINQ statement and use a for/next or for/each.

    What if you only set File_Status in when populating the items, iterate now, does the code hang? If not, set another property and repeat until there is a hang in the code execution.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Wednesday, April 12, 2017 2:18 PM
    Moderator
  • I would first try to make the program in a way that the chance of errors are as low as possible. 

    It looks from the time of the first symbolic program languages like Algol and Fortran. Since Pascal it is not done anymore in this way.

    https://en.wikipedia.org/wiki/Goto


    Success
    Cor

    Wednesday, April 12, 2017 2:53 PM
  • Can you install VS2017 Community, open a copy of the project, run it, and see if the issue still occurs?

    This behavior is odd and your VS is old, so I would want to eliminate the possibility that I was chasing an unknown bug for which there may be no known cure.


    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

    Wednesday, April 12, 2017 4:00 PM
    Moderator
  • Thanks for the advise I wrapped the code in Try Catch and got rid of a application.Run statement I had forgot to remove. It now works great.   
    Wednesday, April 12, 2017 7:22 PM