I can load System.Windows.Forms using below line :
[reflection.assembly]::loadwithpartialname("System.Windows.Forms") | Out-Null
$openFile = New-Object System.Windows.Forms.OpenFileDialog
But not able to load SharePoint assemblies using the similar line script:
[reflection.assembly]::loadwithpartialname("Microsoft.SharePoint.Publishing") | Out-Null
$obj = New-Object Microsoft.SharePoint.Publishing.Design
Getting below error:
New-Object : Cannot find type [Microsoft.SharePoint.Publishing.Design]: verify that the assembly containing this type is loaded`.
Am I doing any mistake. Same with Add-Type.
You are attempting to create an instance of Microsoft.SharePoint.Publishing.Design
but according to the docs , that is a namespace, not a class. You should pass a class to New-Object
. Choose one of the classes from here if you wanted to create something from the Microsoft.SharePoint.Publishing.Design
namespace or choose from here if you wanted to create something from the Microsoft.SharePoint.Publishing
namespace.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.