.NET Assembly Version Conflict

Advertisement

aksarben
Joined:
Posts:
72

.NET Assembly Version Conflict

I suddenly began getting an version error with the .NET Assembly:
Write-Error: Exception calling "Open" with "1" argument(s): "The version of C:\Program Files (x86)\WinSCP\winscp.exe (6.1.2.0) does not match version of this assembly C:\Program Files (x86)\WinSCP\netstandard2.0\WinSCPnet.dll (6.1.1.0)."
I’m guessing it may be caused by a recent WinSCP software update.

I tried downloading & installing the (hopefully) newer version of the .NET Assembly from the WinSCP site, but I then I got a different error message:
Write-Error: 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)'."
Debug log is attached.
My PSVersionTable:
PSEdition                      Core
GitCommitId                    7.3.7
OS                             Microsoft Windows 10.0.19045
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
What do I have to do to make this work?

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,441
Location:
Prague, Czechia

Re: .NET Assembly Version Conflict

In general, you should not rely on installed version of WinSCP. Use a copy of WinSCP.exe compatible with your WinSCPnet.dll.

The "Method not found" error happens, when you are trying to use .NET Framework build of the assembly on .NET [Core].
See https://winscp.net/eng/docs/library_install#build
and Method not found: ‘Void System.Threading.EventWaitHandle..ctor(…)’

Reply with quote

aksarben
Joined:
Posts:
72

.NET Assembly Version Conflict

Thanks for the reply, Martin. I finally got this to work.

I think a key part of the documentation is somewhat ambiguous, which led to my confusion. Specifically, the sentence that reads “PowerShell: No additional installations steps are needed.” If I’m correct, there IS an additional step PowerShell users need to take. You must do one of the following:
  • Set the Session.ExecutablePath property, OR

  • Copy WinSCPnet.dll from the netstandard2.0 subfolder one level up, to the folder containing WinSCP.exe.
Am I correct? Might be worth a few minutes to clarify the documentation on this point.

Reply with quote

Advertisement

You can post new topics in this forum