Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PowerShell runtime exception - "could not load file or assembly"

This seems to be a common problem in PowerShell and Visual Studio, yet cases and solutions seem to vary a lot. Though seeing several similar questions, I didn't find a working solution for my issue yet.

The problem exists in the error message

Could not load file or assembly 'file:///C:\users\jenstmar\Desktop\WinSCP.dll' o r one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)

The file location is invalid, as the .dll is supposed to be located in the same folder as the WinSCP installation. This location was changed to check that no rights or lack thereof, restricted me to use it.

The script line that causes the problem looks as following:

# Load WinSCP .NET assembly
[Reflection.Assembly]::LoadFrom("C:\users\jenstmar\Desktop\WinSCP.dll") | Out-Null

This error comes in both PowerShell ISE and PS ISE(x86). I run PowerShell V3.0 in a Windows Enterprise 64 bit environment as local administrator. How can I fix this problem?

like image 789
Mark Jenster Avatar asked Dec 10 '12 10:12

Mark Jenster


1 Answers

The file may be blocked from being loaded because of its origin (stored in NTFS streams). Check properties and see if the little unblock button is lit up. Once you unblock it perhaps it will load...

like image 91
Chris N Avatar answered Oct 04 '22 12:10

Chris N