2

I want to add my custom web part in master page using SharePoint Designer.

I tried but I am receiving the error shown below.

enter image description here

And this is the description of error.

ExecuteRequestInSandBox call failed. System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.SharePoint.WebPartPages.BinaryWebPartSerializer.Serialize(PersonalizationScope scope, BinaryWebPartSerializerFlag binaryWebPartSerializerFlags, BinaryWebPartSerializerWriter writer) at Microsoft.SharePoint.WebPartPages.BinaryWebPartSerializer.Serialize(SerializationMode mode, BinaryWebPartSerializerFlag binaryWebPartSerializerFlags, BinaryWebPartSerializerWriter writer) at Microsoft.SharePoint.WebPartPages.SPUserCodeWebPart.EnsurePersistedBlobsMatchPropertiesCollection() at Microsoft.SharePoint.WebPartPages.SPUserCodeWebPart.GetWebPartDataForRemoteCall(Object& viewState, Object& controlState) at Microsoft.SharePoint.UserCode.SPUserCodeWebPartRemoteExecutionHelper.ExecuteRequestInSandBox(HttpContext context, SPWeb web, SPWebPartManager manager, SPUserCodeWebPart userCodeWebPart)

enter image description here

6
  • What/how did you try to add your custom web part? Apr 5, 2016 at 7:27
  • How did you added web part in master page? Can you provide some code ? Apr 5, 2016 at 8:24
  • i followed the link mension to add as above for adding web part to master page,and i also tried same with the designer option using browser where we are using snippet section to get html of web part to place in html page associated to a master page like seattle.html and seattle.master where added the code web part in.html page but there also it shows the same error
    – Madhav
    Apr 5, 2016 at 8:54
  • Try this: ukreddysharepoint2010.blogspot.in/2014/05/…
    – P S
    Apr 5, 2016 at 10:27

1 Answer 1

3

Get full qualified assembly of SharePoint solution from visual studio using following steps:

Open Visual Studio
Go to Tools –> External Tools –> Add
    Title: Get Qualified Assembly Name
    Command: Powershell.exe
    Arguments: -command "[System.Reflection.AssemblyName]::GetAssemblyName(\"$(TargetPath)\").FullName"
    Check "Use Output Window".

Register webpart in master page like:

<%@ Register TagPrefix="WpNs" Namespace="SPDemo.NewWebpart" Assembly="SPDemo, Version=1.0.0.0, Culture=neutral, PublicKeyToken=2c5bae03c7cf380a"%>

Add webpart where you want to add like:

<WpNs:NewWebpart ID="testid" runat="server"></WpNs:NewWebpart>

It will work

25
  • Thank You so much for your kind reply, the article i have followed i.e enjoysharepoint.com/Forum/Details/… this article also tells the same way as you mentiond,but still i followed your steps as you said but no change in result.
    – Madhav
    Apr 5, 2016 at 11:15
  • Yes, you have done that. But deploy solution globally and verify your fully qualified assembly. Before few days, i have already done this.It's worked perfectly. That's why i am replying you again. Apr 5, 2016 at 11:22
  • my bad luck ,it's not working.but thank you Viraj
    – Madhav
    Apr 5, 2016 at 11:44
  • Welcome. Can you post here your registration code line and webpart line? Apr 5, 2016 at 11:46
  • this is the registration line <%@ Register TagPrefix="WpNs0" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    – Madhav
    Apr 5, 2016 at 12:16

Your Answer

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

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