Could not load file or assembly ‘file:///…\WinSCPnet.dll’ or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.
The latest version of WinSCP .NET assembly targets .NET Framework 4.0 and .NET Standard 2.0.
You are attempting to load the assembly with an older version of .NET.
You can get this error even if your system has the required version of .NET installed, if you are loading the assembly in an environment that has (an older version of) .NET loaded already. This typically happens with older versions of PowerShell. To fix this, either upgrade your PowerShell version, or have your old PowerShell version load newer version of .NET. You can use COMPLUS_version
environment variable for that:
set COMPLUS_version=v4.0.30319
powershell
For details and other options, see How can I run PowerShell with the .NET 4 runtime?