Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

martin

Re: RE: .Net Library - Specify the WinSCP.exe Path

TheCliGuy wrote:

Question - Does the WinSCP .NET assembly expose any way to check the version number? If not, would it be possible to add such a thing, perhaps a static attribute, for example something like [WinSCP.Information]::Version.

To get a (product) version of an assembly file, use:
[Diagnostics.FileVersionInfo]::GetVersionInfo("WinSCPnet.dll").ProductVersion

To get a a path to the loaded assembly, use:
([Type]([WinSCP.Session])).Assembly.Location
TheCliGuy

RE: .Net Library - Specify the WinSCP.exe Path

I now understand the problem. It's not a WinSCP issue, it's due to the way assembly loading is handled in PowerShell/.Net...

This is what happened...
1. Launched powershell.exe.
2. Ran a script that loaded the WinSCP 5.17.8 DLL (Add-Type -Path "C:\Program Files (x86)\WinSCP\WinSCPnet.dll").
3. Ran a script that loaded the WinSCP 5.18 beta DLL (Add-Type -Path "C:\Bitbucket\WinSCP-5.18.beta-Automation\WinSCPnet.dll").

I didn't realise that the PowerShell session now had two versions of the WinSCP assembly loaded:

(get-item ([System.AppDomain]::CurrentDomain.GetAssemblies()).Where({$_.Location -like "*WinSCP*"}).Location).VersionInfo | Select-Object ProductVersion, FileName


ProductVersion FileName
-------------- --------
5.17.8.0       C:\Program Files (x86)\WinSCP\WinSCPnet.dll
5.18.0.0       C:\Bitbucket\WinSCP-5.18.beta-Automation\WinSCPnet.dll


When I ran the second script, PowerShell implicitly used the first version of the DLL to be loaded.

Question - Does the WinSCP .NET assembly expose any way to check the version number? If not, would it be possible to add such a thing, perhaps a static attribute, for example something like [WinSCP.Information]::Version.
martin

Re: .Net Library - Specify the WinSCP.exe Path

It should work the way you want automatically. Please set Session.DebugLogPath and attach the log.
TheCliGuy

.Net Library - Specify the WinSCP.exe Path

I currently have WinSCP 5.17.8 installed in C:\Program Files (x86)\WinSCP.

I wanted to test the .Net library for 5.18 beta, so I downloaded it and extracted to C:\Bitbucket\WinSCP-5.18.beta-Automation.

In a PowerShell script I load the library as follows:
Add-Type -Path "C:\Bitbucket\WinSCP-5.18.beta-Automation\WinSCPnet.dll"

The script appears to be using WinSCP Version 5.17.8 in C:\Program Files (x86)\WinSCP instead of 5.18 beta in C:\Bitbucket\WinSCP-5.18.beta-Automation, see log excerpt:
. 2020-12-28 16:46:56.175 WinSCP Version 5.17.8 (Build 10803) (OS 10.0.18363 - Windows 10 Enterprise)

. 2020-12-28 16:46:56.175 Configuration: nul
. 2020-12-28 16:46:56.175 Log level: Normal
. 2020-12-28 16:46:56.175 Local account: SANBOX01\TheCliGuy
. 2020-12-28 16:46:56.175 Working directory: C:\Program Files (x86)\WinSCP
. 2020-12-28 16:46:56.175 Process ID: 1496
. 2020-12-28 16:46:56.175 Command-line: "C:\Program Files (x86)\WinSCP\winscp.exe" /xmllog="C:\Users\TheCliGuy\AppData\Local\Temp\wscp2028.00C40AE0.tmp" /xmlgroups /xmllogrequired /nointeractiveinput /dotnet=5.17.8  /ini=nul /log="C:\Bitbucket\WinSCP-Testing\winscp-20201228-164656.log"  /console /consoleinstance=_8232_41281898_190

How can I force the WinSCP .Net library to use C:\Bitbucket\WinSCP-5.18.beta-Automation\WinSCP.exe?