Cannot Load Assembly in powershell

Advertisement

Patrick.Wall
Joined:
Posts:
2
Location:
TN

Cannot Load Assembly in powershell

Hey everyone,

Ive downloaded the files and followed the directions to the best of my ability, but am having trouble loading the WinSCP.dll into my powershell application. I downloaded the portable package and the dll and put them in my pwd. Basically my structure looks like this:

.\Bin\My-PowershellScript.ps1
.\Bin\WinSCP.dll
.\Bin\WinSCP.com
.\Bin\WinSCP.exe

When I execute My-Powershell.ps1 out of the .\Bin directory and call the line
[Reflection.Assembly]::LoadFrom("Full Path to WinSCP.dll") and I get the following error.

Exception calling "LoadFrom" with "1" argument(s): "Could not load file or assembly 'file:///C:\Users\PATH TO WinSCP.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT:
0x80131515)"
At C:\PATH TO My-PowershellScript.ps1.ps1:16 char:40
+ [System.Reflection.Assembly]::LoadFrom <<<< ("C:\Users\PATH TO WinSCP.dll") | Out-Null
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException

I've read the documentation over and again, and ive looked at all the other threads on loading .dlls into powershell and can't make any headway. Anybody have any ideas for help?

Reply with quote

Advertisement

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

Re: Cannot Load Assembly in powershell

What packages have you downloaded (exact names)? What version of .NET do you have installed?

Reply with quote

Patrick.Wall
Joined:
Posts:
2
Location:
TN

Um, in C:\Windows\Microsoft.NET\Framework I have v1.0.3 v1.1.4 v2.0.5 v3.0 v3.5 v4

From powershell [System.Reflection.Assembly]::GetExecutingAssembly().ImageRuntimeVersion yields v2.0.50727

I have in my pwd WinSCP.exe and WinSCP.com from version 5.0.7 and WinSCP.dll from the same.

For what its worth, I am receiving this update when I execute this script from PowerGUI script editor, I do not receive the error when I run from powershell command line. There must be something I have misconfigured in PowerGUI. When I made this post, I hadn't tried running from powershell command line. :shock:

Reply with quote

Advertisement

You can post new topics in this forum