2015-10-07 59 views
0

我可以使用下面一行加载System.Windows.Forms的:负载的SharePoint大会在PowerShell中

[reflection.assembly]::loadwithpartialname("System.Windows.Forms") | Out-Null 
$openFile = New-Object System.Windows.Forms.OpenFileDialog 

但不能使用类似的行脚本加载的SharePoint组件:

[reflection.assembly]::loadwithpartialname("Microsoft.SharePoint.Publishing") | Out-Null 

$obj = New-Object Microsoft.SharePoint.Publishing.Design 

获得以下错误:

New-Object : Cannot find type [Microsoft.SharePoint.Publishing.Design]: verify that the assembly containing this type is loaded`.

我在做任何错误。与Add-Type相同。

回答

1

您正试图创建Microsoft.SharePoint.Publishing.Design的实例,但根据the docs,这是一个名称空间,而不是一个类。你应该通过一门课到New-Object。如果您想从Microsoft.SharePoint.Publishing.Design命名空间创建某些内容,或者从here中选择,则从here中选择一个类,如果您想从Microsoft.SharePoint.Publishing命名空间创建某些内容。

+0

非常感谢。这确实帮助了很多...... –