[英]Issue loading in different assemblies to Powershell
我一直在嘗試將程序集加載到Powershell中以獲取Sharepoint,並且它們大多數都可以正常工作,如下所示:
Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
但是,當我嘗試添加其他文件路徑的文件時:
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\TEMPLATE\LAYOUTS\ClientBin\Microsoft.SharePoint.Client.Silverlight.dll"
我收到以下錯誤:
“ Add-Type:無法加載一個或多個請求的類型。獲取LoaderExceptions屬性以獲取更多信息。”
有人能幫忙嗎?
----- -----更新
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
#Bind to site collection
$Context = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$Creds = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($User,$Password)
$Context.Credentials = $Creds
#Retrieve list
$List = $Context.Web.Lists.GetByTitle($DocLibName)
$Context.Load($List)
$Context.ExecuteQuery()
$SPFolder = New-Object Microsoft.SharePoint.Client.Folder
Microsoft.SgarePoint.Client.Folder
在多個程序集中定義,每個支持此功能的平台一個。 鑒於Powershell在桌面CLR上運行,您只需要加載桌面版本的程序集:
Microsoft.SharePoint.Client.Silverlight(在Microsoft.SharePoint.Client.Silverlight.dll中);
Microsoft.SharePoint.Client.Phone(在Microsoft.SharePoint.Client.Phone.dll中)Microsoft.SharePoint.Client(在Microsoft.SharePoint.Client.dll中)
您需要傳遞正確的構造函數參數:
public Folder(
ClientRuntimeContext context,
ObjectPath objectPath
)
但是我想使用以下方法( GetFolderByServerRelativeUrl
)會更容易。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.