This project has moved. For the latest updates, please go here.
2

Resolved

PowerShell not load assembly

description

Hello,

i get this error, a have installed SDK (online, 2013). Please help.

Add-Type : Could not load file or assembly 'file:///D:\Install\SharePoint Online Client Browser v2.2\Microsoft.SharePoi
nt.Client.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)
At C:\Users\jirka\AppData\Local\Temp\SPCB_PowerShell_OpenSite.ps1:24 char:9
  • Add-Type -Path (Resolve-Path $assemblyName)
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    • CategoryInfo : NotSpecified: (:) [Add-Type], FileLoadException
    • FullyQualifiedErrorId : System.IO.FileLoadException,Microsoft.PowerShell.Commands.AddTypeCommand

comments

BdeJager wrote Jan 18 at 8:27 AM

Hi, sorry to hear this is not working for you!

Can you start the PowerShell via the button in the SharePoint Client Browser. It will fail very likely. Once at the prompt type "$scriptLocation". This will show the script location. Open the script in PowerShell ISE and try debugging the script by running it. This should help resolving the issue.

Let me know if this works for you?!

robinbreman wrote Jan 31 at 11:03 AM

I get the same bug, but debugged the script you mentioned.

When i change the Load-Assembly function to first check the 16\isap folder for installed assemblies the script works.
function Load-Assembly([string]$assemblyName, [string]$sdkVersion) {
    $isapiPath = "$($env:CommonProgramFiles)\Microsoft Shared\Web Server Extensions\16\ISAPI"
    Write-Host $isapiPath - $assemblyName - $sdkVersion
   
    if (Test-Path "$isapiPath\$assemblyName") {
        Add-Type -Path "$isapiPath\$assemblyName"
    }
    elseif (Test-Path $assemblyName) {
        Add-Type -Path (Resolve-Path $assemblyName)
    }
    else {
        [System.Reflection.Assembly]::LoadWithPartialName($assemblyName)
    }
}
Now powershell will connect!

wrote Jan 31 at 11:07 AM

BdeJager wrote Feb 1 at 7:37 AM

I made a fix to solve this issue. PowerShell should be loading its assemblies correctly. I made updates to the CSOM and this caused the issue. Shuffled some assemblies and folders...

Well it should be fixed, please download the latest version from Downloads.

Let me know if this fixes it! Thanks for the feedback.

Bram

robinbreman wrote Feb 7 at 1:11 PM

PowerShell still tries to load the wrong assemblies.
I suggest trying to load the sdk versions first before trying to load the assemblies distributed.
WARNING: Optionally you need the SharePoint Online Client Components SDK,
http://www.microsoft.com/en-us/download/details.aspx?id=42038

Add-Type : Could not load file or assembly 'file:///D:\SharePoint Online Client Browser v3.1\Micros
oft.SharePoint.Client.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)