"The version of WinSCP.exe does not match version of this assembly" when using WinSCP .NET assembly in SSIS package

Viewed 99

I am trying to move files through SFTP using WinSCP. The current version I'm using is working for all other SSIS packages. But when it comes to specific package I'm getting this error. Can you please tell me what happened here?

Error: Error when using WinSCP to upload files: WinSCP.SessionLocalException: The version of C:\Program Files (x86)\WinSCP\WinSCP.exe (5.19.6.0) does not match version of this assembly C:\Windows\Microsoft.Net\assembly\GAC_MSIL\WinSCPnet\v4.0_1.8.3.11933__2271ec4a3c56d0bf\WinSCPnet.dll (5.19.5.0). at WinSCP.ExeSessionProcess.CheckVersion(String exePath, FileVersionInfo assemblyVersion) at WinSCP.ExeSessionProcess..ctor(Session session, Boolean useXmlLog, String additionalArguments) at WinSCP.Session.Open(SessionOptions sessionOptions) at ST_0a7630562a8e496eabffcc08e8282a4d.ScriptMain.Main()

1 Answers

I believe the error is pretty much clear. Your SSIS package is using a different version of WinSCP .NET assembly (WinSCPnet.dll, 5.19.5) than WinSCP version you have installed on that machine (WinSCP.exe, 5.19.6).

Make sure you have the latest versions of both.

Though you better not rely on the installed version of WinSCP, as that might change independently of your SSIS package. You better place a separate copy of WinSCP.exe to a location dedicated to your SSIS package. And use Session.ExecutablePath in your SSIS package WinSCP code to point to it.

See also the official WinSCP SSIS example.


Quoting documentation on Installing the WinSCP .NET assembly:

Installing

The package includes the assembly itself (winscpnet.dll) and a required dependency, WinSCP executable winscp.exe.

The binaries interact with each other and must be kept in the same folder for the assembly to work. In rare situations this is not possible (e.g. when installing the assembly to GAC), make use of the Session.ExecutablePath property to force the assembly to look for the winscp.exe in a different location.

Related