bramdejager / spcb

The SharePoint Client Browser (SPCB) uses the CSOM to connect to a remote SharePoint site collection and shows the site structure with related properties and values.
GNU General Public License v2.0
174 stars 48 forks source link

PowerShell not load assembly #50

Open bramdejager opened 6 years ago

bramdejager commented 6 years ago

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

#### This work item was migrated from CodePlex
CodePlex work item ID: '65581'
Assigned to: 'BdeJager'
Vote count: '2'
bramdejager commented 6 years ago

[BdeJager@18-1-2017] 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?!

bramdejager commented 6 years ago

[robinbreman@31-1-2017] 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!

bramdejager commented 6 years ago

[UnknownUser@31-1-2017]

bramdejager commented 6 years ago

[BdeJager@31-1-2017] 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

bramdejager commented 6 years ago

[robinbreman@7-2-2017] 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)