在SSiS 2008 R2中执行脚本任务时,我在打开的SFTP连接线 sFtpConnection.Connect(); 上收到以下错误:

SSIS包“avande_auth_response.dtsx”开始 . 错误:脚本任务中的0x0,SFTP脚本任务:错误:对象引用未设置为对象的实例 . 警告:脚本任务为0x80019002:SSIS警告代码DTS_W_MAXIMUMERRORCOUNTREACHED . 执行方法成功,但引发的错误数(1)达到允许的最大值(1);导致失败 . 当错误数达到MaximumErrorCount中指定的数量时,会发生这种情况 . 更改MaximumErrorCount或修复错误 . 任务失败:脚本任务警告:位于avande_auth_response的0x80019002:SSIS警告代码DTS_W_MAXIMUMERRORCOUNTREACHED . 执行方法成功,但引发的错误数(1)达到允许的最大值(1);导致失败 . 当错误数达到MaximumErrorCount中指定的数量时,会发生这种情况 . 更改MaximumErrorCount或修复错误 . SSIS包“avande_auth_response.dtsx”完成:失败 .

以下是 C# 脚本的一部分( SftpDownloadDirctory 变量用作ReadOnly, SftpFileExists 变量用作ReadWrite):

using System;
using System.Collections;
using System.Data;
using Microsoft.SqlServer.Dts.Runtime;
using System.Windows.Forms;
using System.IO;
using System.Net;
.
.
.
 public void Main()
 {
        Try
        {
                // Get the ftp connection from the Connection Managers collection
                ConnectionManager sftpServer = Dts.Connections["avande.SFTP"];

                // Create a FTP connection object and use the credentials of connection manager
                FtpClientConnection sFtpConnection = new FtpClientConnection(sftpServer.AcquireConnection(null));

                // Open the connection
                sFtpConnection.Connect();

                // Set work folder with the value of the variable
                sFtpConnection.SetWorkingDirectory(Dts.Variables["User::SftpDownloadDirctory"].Value.ToString());

                // Create StringArrays for filenames and folders
                // The folderNames aren't used, but, it is mandatory for the next method.
                String[] fileNames;
                String[] folderNames;

                // Get a directory listing and fill the StringArray variables
                sFtpConnection.GetListing(out folderNames, out fileNames);

                if (fileNames != null)
                {
                    // Copy StringArray to ArrayList to fit in Object variable
                    ArrayList fileNamesArray = new ArrayList(fileNames);

                    // Fill ssis object variable
                    Dts.Variables["User::SftpFileList"].Value = fileNamesArray;
                }

                // Close connection
                sFtpConnection.Close();

                // Close Script Task, set result to success
                Dts.Variables["User::SftpFileExists"].Value = true;
            }
            catch (Exception ex)
            {
                // Fire error and set result to failure
                Dts.Events.FireError(0, "SFTP Script Task", "Error: " + ex.Message, string.Empty, 0);
                //Dts.TaskResult = (int)ScriptResults.Failure;
                Dts.Variables["User::SftpFileExists"].Value = false;
            }

        }
 }

我已经做了很长一段时间了 .

非常感谢任何解决方案 .