小编Ktn*_*tel的帖子

使用 WinSCP .NET 的方法未找到异常 (EventWaitHandle..ctor)

我正在尝试使用 PowerShell 并使用 WinSCP .NET 程序集连接到 SFTP 服务器。

代码无法打开会话 ( $session.Open($sessionOptions))。

在我发现的日志中,

Exception: System.MissingMethodException: Method not found: 'Void System.Threading.EventWaitHandle..ctor(Boolean, System.Threading.EventResetMode, System.String, Boolean ByRef, System.Security.AccessControl.EventWaitHandleSecurity)'. at WinSCP.ExeSessionProcess.TryCreateEvent(String name, EventWaitHandle& ev) at WinSCP.ExeSessionProcess.InitializeConsole() at WinSCP.ExeSessionProcess.Start() at WinSCP.Session.Open(SessionOptions sessionOptions) [2019-03-14 10:59:02.835Z] [0013] Session.Cleanup entering [2019-03-14 10:59:02.835Z] [0013] Terminating process

基本上,它从$session.Open($sessionOptions)to跳转到$session.Dispose()并跳过代码的其他部分。

我试图在 WinSCP 论坛上找到解决方案,但没有帮助:https ://winscp.net/forum/viewtopic.php?t
=26140

try {
    Add-Type -Path "M:\AMA\ztemp_powershell\WinSCPnet.dll" 

    $sessionOptions = New-Object WinSCP.SessionOptions -Property @{
        Protocol = [WinSCP.Protocol]::Sftp
        HostName = "abc.xyz.ca"
        UserName = "abc_abc"
        Password = …
Run Code Online (Sandbox Code Playgroud)

.net powershell sftp winscp winscp-net

5
推荐指数
1
解决办法
1190
查看次数

标签 统计

.net ×1

powershell ×1

sftp ×1

winscp ×1

winscp-net ×1