51CTO博客地址:https://blog.51cto.com/1396817
博客園博客地址:https://www.cnblogs.com/bxapollo
今天有遇到呼叫Microsoft.SharePoint.Client.dll的方法獲取資料,在執行PowerShell加載SharePoint Online Assemblies時出現例外,執行PowerShell命令如下:
- Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
- Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
錯誤例外如下圖所示:

排錯:查看了對應目錄發現該dll檔案是存在的,那么為什么會出現例外呢?

解決方案:在查找大量資料后,發現可能是.net 4.0的一個bug,默認的情況下禁用從遠程位置加載的程式集中執行代碼的功能,所以可以使用如下方法解決問題:
[System.Reflection.Assembly]::LoadFrom(),

相關資料連接:Assembly.LoadFrom方法
總結該問題的解決方案,希望能對其他有問題的小伙伴帶來幫助,謝謝閱讀,
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/248932.html
標籤:其他
上一篇:SharePoint 解決方案: SharePoint Online Assemblies 加載例外解決方案
下一篇:一次Vue代碼bug定位
