[英]“Cannot execute script because the script entry point is invalid” error in script task in SSIS
I am trying to upload files from my local folder to SFTP using SSIS Script Task. 我正在尝试使用SSIS脚本任务将文件从本地文件夹上传到SFTP。 On replicating the script from https://winscp.net/eng/docs/library#csharp I get an error 从https://winscp.net/eng/docs/library#csharp复制脚本时出现错误
Error: Cannot execute script because the script entry point is invalid. 错误:无法执行脚本,因为脚本入口点无效。
Below is the complete script: 以下是完整的脚本:
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);
}
}
return 0;
}
catch (Exception e)
{
Console.WriteLine("Error: {0}", e);
return 1;
}
}
}
}
}
I would appreciate if someone can help me with this error. 如果有人可以帮我解决这个错误,我将不胜感激。
As WinSCP example for SSIS shows , the signature should be like: 正如SSIS的WinSCP示例所示 ,签名应如下所示:
[AddIn("ScriptMain", Version = "1.0", Publisher = "", Description = "")]
public partial class ScriptMain : VSTARTScriptObjectModelBase
{
public void Main()
{
// ...
}
}
Particularly, remove the nested upload
class. 特别是,删除嵌套的upload
类。
According to this Msdn article : 根据这篇Msdn文章 :
Make sure in the script task's editor, the Script page's Entry Point property is set to ScriptMain. 确保在脚本任务的编辑器中,“脚本”页面的“入口点”属性设置为ScriptMain。
Additional Informations 其他信息
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.