我正在尝试使用 SSIS 脚本任务将文件从我的本地文件夹上传到 SFTP。从https://winscp.net/eng/docs/library#csharp复制脚本时,出现错误错误:无法执行脚本,因为脚本入口点无效。下面是完整的脚本:using System;using System.Data;using Microsoft.SqlServer.Dts.Runtime;using System.Windows.Forms;using WinSCP;namespace ST_1ae95a63b20641ffb8ed1769503e2841{ [Microsoft.SqlServer.Dts.Tasks.ScriptTask.SSISScriptTaskEntryPointAttribute] public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase { #region Help: Using Integration Services variables and parameters in a script class upload { public static int Main() { try { SessionOptions sessionOptions = new SessionOptions { Protocol = Protocol.Sftp, HostName = "a.com", UserName = "btest", Password = "c", SshHostKeyFingerprint = "ssh-rsa 2048 avc", }; using (Session session = new Session()) { // Connect session.Open(sessionOptions); // Upload files TransferOptions transferOptions = new TransferOptions(); transferOptions.TransferMode = TransferMode.Binary; TransferOperationResult transferResult; transferResult = session.PutFiles(@"d:\abc\efdg\*", "/cvf/pqr/", false, transferOptions); // Throw on any error transferResult.Check(); // Print results foreach (TransferEventArgs transfer in transferResult.Transfers) { Console.WriteLine("Upload of {0} succeeded", transfer.FileName); } }如果有人可以帮助我解决此错误,我将不胜感激。
2 回答
波斯汪
TA贡献1811条经验 获得超4个赞
正如SSIS 的 WinSCP 示例所示,签名应如下所示:
[AddIn("ScriptMain", Version = "1.0", Publisher = "", Description = "")]
public partial class ScriptMain : VSTARTScriptObjectModelBase
{
public void Main()
{
// ...
}
}
特别是,删除嵌套upload类。
- 2 回答
- 0 关注
- 259 浏览
添加回答
举报
0/150
提交
取消