Welcome to my blog on all things SharePoint. I have a range of articles that will interest you if you've made it as far as visiting my blog. I was awarded as an SharePoint MVP by Microsoft in July 2010. I currently live in New York and am an Enterprise Architect at AvePoint Inc.. I co founded www.NothingButSharePoint.com with Mark Miller in 2010.

MVP AwardJeremy Thake Profile Photo

Whitepapers

NBSP

Check out my articles on NothingButSharePoint.com

Solution Development in SharePoint 2007

This series was inspired by the chatter amongst SharePoint blogs on the best ways to approach customisations in SharePoint using Solutions.

Part 1 - Part 2 - Part 3 - Part 4 - Part 5 - Part 6 - Part 7 - Part 8

Leveraging the SharePoint Platform

This series was inspired by a discussion had with Andrew Coates at a Perth SharePoint User Group meeting. This then turned into a 6 part series on Arno Nell's SharePointMagazine.net web site.

Initial post - Part 1 - Part 2 - Part 3 - Part 4 - Part 5 - Part 6

Webcasts

I have recorded various web casts that I present at User Groups or just on a specific topic by request:
How ASP.NET Developers can leverage SharePoint webcast
SPSource Webcast: Reverse engineer Lists to ListTemplates and much more
SharePoint Development with Unit Testing webcast
Perth SharePoint UG Web Cast on approaches to deploying artefacts (SPSource)
More...


Podcasts

I have been interviewed about Leveraging the SharePoint Platform by the SharePoint Pod Show: listen here .

RSS Feed Feed your read!

Archives

November 2012 (6)
October 2012 (8)
September 2012 (4)
August 2012 (7)
July 2012 (13)
June 2012 (4)
March 2012 (1)
February 2012 (1)
January 2012 (5)
September 2011 (2)
August 2011 (1)
July 2011 (3)
June 2011 (7)
May 2011 (3)
April 2011 (3)
March 2011 (3)
February 2011 (2)
January 2011 (1)
December 2010 (4)
September 2010 (4)
July 2010 (5)
June 2010 (4)
May 2010 (6)
April 2010 (7)
March 2010 (5)
February 2010 (7)
January 2010 (3)
December 2009 (1)
November 2009 (6)
October 2009 (9)
September 2009 (7)
August 2009 (6)
July 2009 (13)
June 2009 (4)
May 2009 (12)
April 2009 (4)
March 2009 (4)
February 2009 (13)
January 2009 (4)
December 2008 (4)
November 2008 (11)
October 2008 (16)
September 2008 (4)
August 2008 (5)
July 2008 (4)
June 2008 (8)
May 2008 (5)
April 2008 (9)
March 2008 (5)
February 2008 (6)
January 2008 (1)
November 2007 (11)
October 2007 (8)
September 2007 (24)
August 2007 (5)
July 2007 (2)
May 2007 (1)
April 2007 (1)
March 2007 (1)
February 2007 (3)
January 2007 (4)
November 2006 (7)
October 2006 (7)
September 2006 (18)
August 2006 (14)
June 2006 (3)
May 2006 (8)
April 2006 (4)
March 2006 (38)
February 2006 (30)
January 2006 (2)
December 2005 (3)
November 2005 (28)
May 2005 (1)
April 2005 (5)
March 2005 (1)
November 2004 (1)
August 2004 (11)
July 2004 (1)
Failed to render control: An error occurred during a call to extension function 'createMonthUrl'. See InnerException for a complete description of the error.

Links

Tag Cloud

Ajax, Apple, DotNetNuke, Enterprise Content Management, Error Resolution, Gadgets, General, Governance, Microsoft .Net Development, Mobile, SharePoint, Sharepoint Business Forms, Sharepoint Business Intelligence, Sharepoint Collaboration, SharePoint Development, Sharepoint Enterprise Content Management, Sharepoint Enterprise Search, Sharepoint Portal, US Migration, Web 2.0, Workflow

Site Definition Issues - File or arguments not valid for site template 'CustomPortalTemplate#0'   

Tags:
Technorati Tags:

I’ve recently had to finally take a look at Site Definitions after always taking the approach of creating a blank site and using Features to build up a site.

03/31/2009 20:32:52.05     Quest.PowerGUI.ScriptEditor.exe (0x102C)    0x11B0    Windows SharePoint Services       General                           8e27    Medium      Ensuring module folder _catalogs/masterpage    

03/31/2009 20:32:52.13     Quest.PowerGUI.ScriptEditor.exe (0x102C)    0x11B0    Windows SharePoint Services       Topology                          95ks    Critical    The site /sites/InfoNetDev could not be created.  The following exception occured: File or arguments not valid for site template 'CustomPortalTemplate#0'..

The issue I was having was that I could create the Site Collection using Central Administration, but when I tried to create the site collection using the object model in PowerShell it was throwing the above error!

The reason I wanted to do this was so that I could use automated scripts to setup and tear down the Site Collection…not a big fan of the web UI for speed ;-)

function create-spsite ([String] $url, [String] $OWNERACCOUNT, [String] $OWNEREMAIL)
{
    $uri = new-object -TypeName System.Uri -ArgumentList "$url"
    $exists = ([type]"Microsoft.SharePoint.SPSite")::Exists($uri);
    if ($exists)
    {
        "Deleting Staging SPSite"
        $site = new-object -TypeName "Microsoft.SharePoint.SPSite" -ArgumentList "$uri";
        $site.Delete();
        $site.Dispose();
    }
    "Creating SPSite"
    $webApplication = ([type]"Microsoft.SharePoint.Administration.SPWebApplication")::Lookup($uri);
    $webApplication.Sites.Add($uri, "InfoNet", "", 1033, "PortalPortalCollection#0", $OWNERACCOUNT, "owner", $OWNEREMAIL);
}

I tried to ensure that the Web Templates were in there, using GetWebTemplates() command. The PowerShell was as follows:

[System.Reflection.Assembly]::LoadFrom("$12HivesDir\ISAPI\Microsoft.SharePoint.dll");
$globalAdmin = New-Object -TypeName "Microsoft.SharePoint.Administration.SPGlobalAdmin";
$webTemplates = $globalAdmin.VirtualServers[0].GetWebTemplates("1033");
$webTemplates | Select Name, Description;

But the problem was it wasn’t returning my Site Definitions or Site Templates back!

I left it for the night and came back to it this morning. When I started up my VMs, I ran this command again it showed the Templates. Then when I ran the code to create the site collection using the Object Model it worked too! I didn’t change any of the webTemp.xml files or the site definition xml files either!

There are “remarks'” on the SPSite.GetWebTemplates MSDN page that highlights issue with calling the templates if they have only just been installed by a Solution Package, thanks to @paulschaeflein for pointing me to this URL. I’d also like to thank @AndrewWoody, @flarepoint, @toddklindt and @keutmann for also firing back a few quick answers as I came across things yesterday evening.

RESOLUTION

So what I ended up doing was creating the site collection via stsadm as recommended in the remarks and firing an IISRESET before calling it:

IISRESET

stsadm -o createsite -url $webappUrl -owneremail $OWNEREMAIL -ownerlogin $OWNERACCOUNT -lcid "1033" -sitetemplate "CustomPortalCollection" -title "InfoNet"

Then I just removed the create-spsite powershell function for good measure! The reason this works is that stsadm is fired on another thread and picks up the new Site Templates.

CONCLUSION

So, some of the key things I took away from this (which will end up on the SharePointDevWiki.com shortly):

  • always IISRESET when modify any files in the 12 Hive
  • bear in mind that sometimes the Central Admin and Site User Interface is more forgiving than object model – thanks to @AndrewWoody for his account on his findings!
  • don’t forget your own social bookmarks you’ve collected over the last 3 years on Site Definitions!
  • the webtemplate paramter used in SPSite.Add() is a combination of the <Template> Name and the <Template><Configuration> Id attributes

So my first real customisation experience with Site Definitions has left me bitter and twisted, but not defeated!

 
Posted by  Jeremy Thake  on  3/31/2009
0  Comments  |  Trackback Url  | 0  Links to this post | Bookmark this post with:        
 

Links to this post

Comments

blog comments powered by Disqus