Re: Resolved: Using the wrong assembly file
@pit5123: This is the right answer, it worked for me as well.
Before posting, please read how to report bug or request support effectively.
Bug reports without an attached log file are usually useless.
Add-Type -Path "D:\Tools\WinSCP\netstandard2.0\WinSCPnet.dll" #Set WinSCP.net dll location
$session = New-Object WinSCP.Session
$session.ExecutablePath="D:\Tools\WinSCP\WinSCP.exe" # Set WinSCP.exe path and the error gone
$session.DebugLogPath="D:\xxx.log" #If errors occurred, look into the log file.
netstandard2.0
).
# Load WinSCP .NET assembly
Add-Type -Path "WinSCPnet.dll"
# Set up session options
$sessionOptions = New-Object WinSCP.SessionOptions -Property @{
Protocol = [WinSCP.Protocol]::Sftp
HostName = "hostname.tld"
UserName = "uid"
SshHostKeyFingerprint = "ssh-ed25519 256 XXX="
SshPrivateKeyPath = "path.ppk"
}
$sessionOptions.AddRawSettings("Compression", "1")
$sessionOptions.AddRawSettings("Cipher", "aes,blowfish,chacha20,WARN,3des,des,arcfour")
$sessionOptions.AddRawSettings("KEX", "ecdh,dh-group14-sha1,rsa,WARN,dh-gex-sha1,dh-group1-sha1")
$session = New-Object WinSCP.Session
$session.SessionLogPath = "d:\temp\erg.log"
try
{
# Connect
$session.Open($sessionOptions)
# Your code
}
finally
{
$session.Dispose()
}
$session.Open()
:
MethodInvocationException: Exception calling "Open" with "1" argument(s): "Method not found: 'Void System.Threading.EventWaitHandle..ctor(Boolean, System.Threading.EventResetMode, System.String, Boolean ByRef, System.Security.AccessControl.EventWaitHandleSecurity)'."