Well, SharePoint 2013 is not very Sandbox friendly. Having lots of issues.
In SharePoint 2010, I was able to successfully embed Sandbox webparts inside the masterpage using this:
<WebPartPages:SPUserCodeWebPart runat="server" Description="Description" Title="TITLE"
AssemblyFullName="$SharePoint.Project.AssemblyFullName$" SolutionId="00000000-0000-0000-0000-00000000000"
ID="ID" TypeFullName="Namespace.WP">
</WebPartPages:SPUserCodeWebPart>
However, when I add this inside a masterpage in SharePoint 2013, I get the following 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)
I resolved this (hurrah!) by changing the version of referenced assemblies to 16.0.0.0 from 15.0.0.0 (or rather, removing the version and key parts of the assembly names altogether) in the Register tags.
Basically I think there's a bug in wave 15, fixed in wave 16.
Only problem is, my dev environment is wave 15 (as is everyone else's I presume). But removing the version number from the reference tags, it at least won't crash-out completely, just give an error message where the web part would appear.