动态

详情 返回 返回

SharePoint 解決方案: SharePoint Online Assemblies 加載異常解決方案 - 动态 详情

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方法

 總結該問題的解決方案,希望能對其他有問題的小夥伴帶來幫助,謝謝閲讀。

 

user avatar Johny-zhao 头像 sunhao1234 头像 life512 头像 jianyus 头像
点赞 4 用户, 点赞了这篇动态!
点赞

Add a new 评论

Some HTML is okay.