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: Could not load WinSCP .NET assembly

Make sure you have the latest version of .NET framework and PowerShell installed.
axeconrad

Could not load WinSCP .NET assembly

Hello,
I'm trying to automate file transfer with powershell. I downloaded .NET assembly and write the code in powershell. I encountered a problem when I tried to load WinSCP .NET assembly.This the code to load WinSCP .NET assembly.
Add-Type -Path "C:\Users\TEST\Documents\WinSCP-5.15.2-Automation\WinSCPnet.dll"

And this is the error that I received
Add-Type: Unable to load the file or assembly 'file://C:\Users\TEST\Documents\WinSCP-5.15.2-Automation\WinSCPnet.dll' or one of its dependencies. This assembly has been co

built by a runtime newer than the runtime currently loaded and cannot be loaded.
Level C:\Users\TEST\Desktop\SynchroFile.ps1: 3 Character: 9
+ Add-Type -Path "C:\Users\TEST\Documents\WinSCP-5.15.2-Automation\WinSCPnet.dll"
+ CategoryInfo : NotSpecified: (:) [Add-Type], BadImageFormatException
+ FullyQualifiedErrorId: System.BadImageFormatException,Microsoft.PowerShell.commands.AddTypeCommand

Error: Cannot find the type [WinSCP.Protocol]: check that the assembly in which it is located is loaded.