Home Forums .NET libraries Xceed SFTP/FTP for .NET Parallel.ForEach with XCEED FTP

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #21401 |

    I want to execute parallel ftp jobs with parallel.ForEach task however when I run my program I get

    Unhandled Exception: System.AggregateException: One or more errors occurred. —> Xceed.Ftp.FtpInvalidStateException: Ca
    nnot perform the requested operation because the FTP client is already connected to an FTP server.
       at Xceed.Ftp.FtpClient.SetState(FtpClientState newState)
       at Xceed.Ftp.AsyncFtpClient.BeginConnect(String hostName, Int32 port, AsyncCallback callback, Object state)
       at ParallelTest.Module1.DoIt(vwCompanyDivisionDevice data) in F:\PureAutomation\Projects\FixSus\Development\Samples\P

    For each task I create a new ftpclient object

    Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by Wim (had 1320 views)

    Diane [Xceed]
    Moderator
    Post count: 1353

    Hi Wim,

    When you get the exception, please “drill down” the inner exceptions and report them to us.

    Each System.Exception object contains a InnerException property. You can loop on each inner exception, taking note of each exception along the way until InnerException is null.

    Example (C#):

       try
       {
          // TODO: Code that causes an exception
       }
       catch( Exception exception )
       {
          // Output some information about it
          Console.WriteLine( “–>{0}: {1}\n{2}”, exception.GetType().Name, exception.Message, exception.StackTrace );

          // Fetch the inner exception
          exception = exception.InnerException;

          // While there is an exception
          while( exception != null )
          {
             // Output some information about it
             Console.WriteLine( “–>Inner exception: {0}: {1}\n{2}”, exception.GetType().Name, exception.Message, exception.StackTrace );

             // Fetch the inner exception
             exception = exception.InnerException;
          }
       }

    Example (VB.NET):

       Try
          ‘ TODO: Code that causes an exception
       Catch exception As Exception
          ‘ Output some information about it
          Console.WriteLine(“–>{0}: {1}” & Constants.vbLf & “{2}”, exception.GetType().Name, exception.Message, exception.StackTrace)

          ‘ Fetch the inner exception
          exception = exception.InnerException

          ‘ While there is an exception
          Do While exception IsNot Nothing
             ‘ Output some information about it
             Console.WriteLine(“–>Inner exception: {0}: {1}” & Constants.vbLf & “{2}”, exception.GetType().Name, exception.Message, exception.StackTrace)

             ‘ Fetch the inner exception
             exception = exception.InnerException
          Loop
       End Try

     

    If you have a small stand-alone test project that reproduces the issue that you can send to us, please send it by email to support@xceed.com and include a link to this forum thread for reference. Thank you.

    Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by Diane [Xceed] (had 810 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.