Update Meeting Workspace Theme Programmatically SharePoint 2010

I want to update the theme for a meeting workspace during its creation.

I have added this code to the ONET.xml file (Configuration ID=0) in the MPS Site Template:

<Feature ID="39DD29FB-B6F5-4697-B526-4D38DE4893E5″ />


<ExecuteUrl Url="_layouts/SiteMap/SiteMap.aspx?thmx=1″/>


So in the URL specified above, it passes a parameter used to identify a portion of code to execute in the page_load event.

here is the code in the SiteMap page:

string theme = Request.QueryString.Get("thmx");       if (theme != null)       {         SPWeb thisWeb = SPContext.Current.Web;         SPWeb TempWeb = SwitchUser(thisWeb, thisWeb.Url, "System");         TempWeb.AllowUnsafeUpdates = true;         TempWeb.Update();          SPSite site = new SPSite(SPContext.Current.Site.RootWeb.Url);          ReadOnlyCollection<ThmxTheme> managedThemes = null;         managedThemes = ThmxTheme.GetManagedThemes(site);         foreach (ThmxTheme theme2 in managedThemes)         {           if (theme2.Name == "IH_Custom")           {             //theme2.ApplyTo(TempWeb, true);             ThmxTheme.SetThemeUrlForWeb(TempWeb, theme2.ServerRelativeUrl);             TempWeb.Update();             break;           }         }         TempWeb.AllowUnsafeUpdates = false;         Response.Redirect(TempWeb.Url);       } 

Ignore the switchUser routine; I was just testing to see if the System account was getting the same error.  In both cases (as current user or System) I was getting this error when it hit either of these lines of code to execute:

//theme2.ApplyTo(thisWeb, true);  OR