在SSIS中使用Renci时如何避免崩溃

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了在SSIS中使用Renci时如何避免崩溃相关的知识,希望对你有一定的参考价值。

我正在使用Renci访问我的SSIS包中的SFTP文件

我的包只有一个控件“脚本任务”来执行一些.net代码,我的代码需要Renci引用,所以我将renci.sshnet.dll添加到我的引用。

问题是,当我尝试执行我的包时,我收到此错误消息

enter image description here

我试着注释掉脚本以查看导致错误的原因

我得到了这一行,使执行失败并发送此错误消息

using (var sftp = new SftpClient(host, username, password))

我在Windows Forms C#.net中测试了我的代码,它运行得很好

这是我的包中的代码

    public void Main()
    {
        // TODO: Add your code here
        string host = @"myhost.mydomain.com.au";
        string username = "MyUserName";
        string password = "MyPassword";

        string remoteDirectory = "/SourceFolder/";
        string localDirectory = @"C:Test";

        using (var sftp = new SftpClient(host, username, password))
        {
            sftp.Connect();
            var files = sftp.ListDirectory(remoteDirectory);

            foreach (var file in files)
            {
                string remoteFileName = file.Name;
                if ((!file.Name.StartsWith("."))) //&& ((file.LastWriteTime.Date == DateTime.Today)))

                    using (Stream file1 = File.OpenWrite(localDirectory + remoteFileName))
                    {
                        sftp.DownloadFile(remoteDirectory + remoteFileName, file1);
                    }
            }
        }


            Dts.TaskResult = (int)ScriptResults.Success;
    }
答案

找到了解决方案

1-管理员打开命令提示符

2- cd o安装了“gacutil”的文件夹

3-确保renci.sshnet.dll在c盘中

4-使用gacutil注册

以上是关于在SSIS中使用Renci时如何避免崩溃的主要内容,如果未能解决你的问题,请参考以下文章

EXE崩溃时如何避免提示

避免Android在方向更改时自动重新添加我的片段

重新打开片段时应用程序崩溃

protobuf-net 使用索引属性时如何避免崩溃

如何在 X++(或 C#)中使用 Renci.SshNet 从其他服务器安全地发送文件,你使用端口转发吗?

如何避免 Chrome 在解析此 JSON 时崩溃?