Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I found this article which does a very good job explaining how to add built in web parts (like the content editor webpart). Unfortunately when I tried to add my own I couldn't get it to work. I have the webpart already installed on my sharepoint instance, I have checked the GAC and confirmed that the assembly for my webpart is there, but when I try to run this line:

$webpart = New-Object HighlightsTicker.HighlightsTickerPart.HighlightsTickerPart

I get the error:

New-Object : Cannot find type [HighlightsTicker.HighlightsTickerPart.HighlightsTickerPart]: make sure the assembly containing this type is loaded. At C:\Users\amiessler\AppData\Local\Temp\3\8c524086-dcea-4250-a4b9-0722c51e3d8f.ps1:5 char:22 + $webpart = New-Object <<<< HighlightsTicker.HighlightsTickerPart.HighlightsTickerPart + CategoryInfo : InvalidType: (:) [New-Object], PSArgumentException + FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand

This is what the code for my HightlightsTickerPart.cs looks like namespace/classname wise:

namespace HighlightsTicker.HighlightsTickerPart
{
    [ToolboxItemAttribute(false)]
    public class HighlightsTickerPart : WebPart
    {

Do I need to do something differently to get this to work with a custom webpart?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

You may need to load the assembly containing the web part in your PowerShell Session, if you have not done so already. See below:

http://www.dougfinke.com/blog/index.php/2010/08/29/how-to-load-net-assemblies-in-a-powershell-session/

I think LoadWithPartialName is the way to go in this case.

share|improve this answer
    
I ended up using Load Looks like LoadWithPartialName has been deprecated. Ended up looking like this: [reflection.assembly]::Load("HighlightsTicker, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ccdee482b415afe7") –  Abe Miessler Dec 15 '11 at 16:29

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.