Need help with winSCP

Started by MW4, September 01, 2017, 10:38:02 AM

Previous topic - Next topic

MW4

I have some code:

assemblydir = 'C:\Program Files (x86)\WinSCP'
ObjectClrOption( 'appbase', assemblydir )
ObjectClrOption ( 'use', 'WinSCPnet, Version=1.3.7.7601, Culture=neutral' )

objSessionOptions = ObjectClrNew( 'WinSCP.SessionOptions' )
objProtocol = ObjectClrNew( 'WinSCP.Protocol' )
Sftp = ObjectClrType( 'WinSCP.Protocol', objProtocol.Sftp )

objSessionOptions.Protocol = Sftp 
objSessionOptions.HostName = 'eftp.xxx.biz'
objSessionOptions.UserName = 'xxxxxx'
objSessionOptions.SshHostKeyFingerprint = "ssh-rsa 2048 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

objSession = ObjectClrNew("WinSCP.Session" )

objSession.Open(objSessionOptions)

objTransferOptions = ObjectClrNew( 'WinSCP.TransferOptions' )
objTransferMode = ObjectClrNew( 'WinSCP.TransferMode' )
objTransferOptions.TransferMode = ObjectClrType( 'WinSCP.TransferMode', objTransferMode.Binary )


and it is erroring out with a 1261 COM/CLR: Exception at objSession.Open(objSessionOptions)


Version appears to be right.

Code does run on a 32bit machine compiled, but does not on a 64 bit machine using same 32 bit exe.

Any ideas?

td

Never have had any issues using WinSCP on 64-bit Windows and don't see how the same compiled script could execute on 32-bit Windows because 32-bit Windows doesn't normally have a "Program Files (x86)" folder.

At any rate, you should click the "More Error Info" button on the error message box, if it is enable -  it usually is for CLR errors.  The WinBatch CLR hosting subsystem should give you a good description of the problem as reported by the assembly.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

MW4

I had modifies that portion of the script that pointed to "Program Files (x86)", so I had two versions of the same compiled exe.

Other than that, same script


From the debug trace

[CLR Error]
mscorlib=Could not load file or assembly 'WinSCP, Version=1.3.7.7601, Culture=neutral' or one of its dependencies. The module was expected to contain an assembly manifest.

MW4

I got it...
It was missing this line:

objSessionOptions.SshPrivateKeyPath = "Z:\mypath\Private.ppk"