0

I have mysites active in my SharePoint 2013 environment and I have branding applied via feature stapling however I'm running into two problems, the first one is that when you click on "blog" it throws an error saying "Sorry, something went wrong". When I check the logs to see what it records it says mssearch.exe OpenQuery Failed with Status ID: 0x0000bb8. If I deactivate my branding this error doesn't show and the blog works as expected. Have I perhaps done something wrong or is my branding needing some additional code I haven't included?

In addition to the above error if I click on "Upload Image" from mysites to add an image for my profile picture the window comes up but says "Something went wrong - File not found". Nothing seems to be logged against it that I can see but again if I deactivate my branding it works fine. Can anyone help me get to the bottom of this?

Here is the code for Event Receiver which the Stapler hooks onto:

using System;
using System.Runtime.InteropServices;
using System.Security.Permissions;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Utilities;

namespace My_Sites_Branding.Features.ActivateMySiteBranding
{
    /// <summary>
    /// This class handles events raised during feature activation, deactivation, installation, uninstallation, and upgrade.
    /// </summary>
    /// <remarks>
    /// The GUID attached to this class may be used during packaging and should not be modified.
    /// </remarks>

[Guid("e60d019f-bcbb-43a3-8996-83f46cbbd7aa")]
public class ActivateMySiteBrandingEventReceiver : SPFeatureReceiver
{
    // Uncomment the method below to handle the event raised after a feature has been activated.
    public override void FeatureActivated(SPFeatureReceiverProperties properties)
    {
        SPSite siteCollection = (SPSite)properties.Feature.Parent;
        string masterUrl = SPUrlUtility.CombineUrl(siteCollection.ServerRelativeUrl, "_catalogs/masterpage/CustomProfile.Master");

        foreach (SPWeb web in siteCollection.AllWebs)
        {
            try
            {
                web.MasterUrl = masterUrl;
                web.CustomMasterUrl = masterUrl;
                web.Update();
            }
            catch
            {
                if (web != null)
                    web.Dispose();
                throw;
            }
            if (web != null)
                web.Dispose();
        }
    }

    // Uncomment the method below to handle the event raised before a feature is deactivated.
    public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
    {
        SPSite siteCollection = (SPSite)properties.Feature.Parent;
        string masterUrl = SPUrlUtility.CombineUrl(siteCollection.ServerRelativeUrl, "_catalogs/masterpage/mysite15.master");
        foreach (SPWeb web in siteCollection.AllWebs)
        {
            try
            {
                web.MasterUrl = masterUrl;
                web.CustomMasterUrl = masterUrl;
                web.Update();
            }
            catch
            {
                if (web != null)
                    web.Dispose();
                throw;
            }
            if (web != null)
                web.Dispose();
        }
    }
}

}

Here is my provision handler SubWebProvisioned.cs

using System;
using System.Security.Permissions;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Utilities;
using Microsoft.SharePoint.Workflow;

namespace HarProfiles.FeatureElements.SubWebProvisioned
{
/// <summary>
/// Web Events
/// </summary>
public class SubWebProvisioned : SPWebEventReceiver
{
    /// <summary>
    /// A site was provisioned.
    /// </summary>
    public override void WebProvisioned(SPWebEventProperties properties)
    {
        base.WebProvisioned(properties);

        SPWeb topLevelSite = properties.Web.Site.RootWeb;

        // Calculate relative path to site from Web Application root.
        string webAppRelativePath = topLevelSite.ServerRelativeUrl;
        if (!webAppRelativePath.EndsWith("/"))
        {
            webAppRelativePath += "/";
        }

        properties.Web.MasterUrl = webAppRelativePath + "_catalogs/masterpage/CustomProfiles.master";
        properties.Web.CustomMasterUrl = webAppRelativePath + "_catalogs/masterpage/CustomProfiles.master";                     

        properties.Web.Update();
        }
    }
}
  • Can you add the code that registers the feature stapling please ? – Stefan Bauer Dec 1 '14 at 11:11
  • I've added the code from my SubWebProvisioned.cs file if that's any use. The actual Stapler file is just an elements file. – Yanayaya Dec 1 '14 at 11:32
  • Yeah but I would like to see which template you registered the stapler too. – Stefan Bauer Dec 1 '14 at 13:15
  • <FeatureSiteTemplateAssociation Id="e60d019f-bcbb-43a3-8996-83f46cbbd7aa" TemplateName="SPSPERS#2" /> – Yanayaya Dec 1 '14 at 14:57
  • A friendly bump. – Yanayaya Dec 2 '14 at 10:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.