0

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.

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.