PowerShell/.NET Assembly Error - Recursive calls not allowed

Advertisement

ta0147896325
Joined:
Posts:
3

PowerShell/.NET Assembly Error - Recursive calls not allowed

I receive a "Recursive calls not allowed" error connecting to a Cygwin/OpenSSH system via PowerShell/.NET assembly and issuing a Session.FileExists.

Any recommendation?

Reply with quote

Advertisement

ta0147896325
Joined:
Posts:
3

Re: PowerShell/.NET Assembly Error - Recursive calls not allowed

Thank you for the fix. It works as expected.

Implemented in PowerShell as function at top of script:

function FileExistsFix
{
[WinSCP.Session]$pSession = $args[0]
[string]$pPath = $args[1]
try
{
$pSession.GetFileInfo($pPath)
return $TRUE
}
catch [$pSession.SessionRemoteException]
{
return $FALSE
}
}

And called within main script body as:

if (FileExistsFix $session $remotePath) {
Write-Host "Remote file exists."
}
else
{
Write-Host "Remote file does not exist."
}

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
27,253
Location:
Prague, Czechia

Re: PowerShell/.NET Assembly Error - Recursive calls not allowed

I have sent you an email with a development version of WinSCP to address you have used to register on this forum.
_________________
Martin Prikryl

Reply with quote

ta0147896325
Joined:
Posts:
3

Re: PowerShell/.NET Assembly Error - Recursive calls not allowed

The fix within the development version works without error.

I am able to use the following and works in both cases:

if($session.FileExists($remotePath)) {
{
Write-Host "Remote file exists."
}
else
{
Write-Host "Remote file does not exist."
}

Thank you for all your work!

Reply with quote

Advertisement

You can post new topics in this forum