vivek mishra
vivek mishra

Reputation: 91

Load SharePoint Assembly in powershell

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.

Upvotes: 0

Views: 1121

Answers (1)

ama1111
ama1111

Reputation: 579

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.

Upvotes: 2

Related Questions