SSIS C# 2012 Script Task referring WinSCPnet.dll fails when run from SQL Server Agent with "Exception has been thrown by the target of an invocation"
18:22 17 Dec 2015

I have an SSIS package (created in VS 2013) that contains a C# 2012 Script Task.

The job of the script task is to download a file from an SFTP server using WinSCP .NET assembly and place it on my server (Windows Server 2012 R2 with SQL Server 2014)

My package runs fine when I run it on my Dev machine, but when I deploy to the server my package fails at this task with the error message

Exception has been thrown by the target of an invocation

enter image description here

I've done some digging and it looks like it has something to do with the reference to WinSCPnet.dll.

sql-server visual-studio-2012 ssis winscp winscp-net