When trying to create subsite from a given template anywhere but the top of the site collection, this error occurs:
Unhandled exception was thrown by the sandboxed code wrapper's Execute method in the partial trust app domain:
An unexpected error has occurred. -{group and site Ids here} - Inner Exception: Microsoft.SharePoint.UserCode.SPUserCodeSolutionProxiedException: Value does not fall within the expected range.
Server stack trace: at Microsoft.SharePoint.SPRoleAssignmentCollection.GetAssignmentByPrincipal(SPPrincipal principalToFind) at Microsoft.SharePoint.SPRoleAssignmentCollection_SubsetProxy.GetAssignmentByPrincipal__Inner(SPPrincipal_SubsetProxy principalToFind) at Microsoft.SharePoint.SPRoleAssignmentCollection_SubsetProxy.GetAssignmentByPrincipal(SPPrincipal_SubsetProxy principalToFind) at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs) at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext) Exception rethrown at [0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) at Microsoft.SharePoint.SPRoleAssignmentCollection_SubsetProxy.GetAssignmentByPrincipal(SPPrincipal_SubsetProxy principalToFind) at Microsoft.SharePoint.SPRoleAssignmentCollection.GetAssignmentByPrincipal__Inner(SPPrincipal principalToFind) at Microsoft.SharePoint.SPRoleAssignmentCollection.GetAssignmentByPrincipal(SPPrincipal principalToFind) at Roche.TP.PDCore.Code.Commands.SitePagesRightsCommand.AssignPersonalViewsEditPermission(SPWeb web, SPList sitePages, Int32 groupId) at Roche.TP.PDCore.Code.Commands.SitePagesRightsCommand.Execute(SPFeatureReceiverProperties properties) at Roche.TP.SandboxCommon.Infrastructure.Commands.BaseCommandCollection.Execute(SPFeatureReceiverProperties properties) at Roche.TP.PDCore.Features.Web_PDCore.Web_PDCoreEventReceiver.FeatureActivated(SPFeatureReceiverProperties properties) at Microsoft.SharePoint.UserCode.SPUserCodeFeatureCallOutWrapper.ExecuteInternal(Object userCodeObject, SPUserCodeRemoteExecutionContext context) at Microsoft.SharePoint.UserCode.SPUserCodeRemoteExecutionWrapper.Execute(SPUserCodeExecutionContext executionContext) at Microsoft.SharePoint.UserCode.SPUserCodeApplicationHostAppDomainRef.ExecuteWrapper(SPUserCodeWrapper wrapper, SPUserCodeExecutionContext executionContext) at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs) at System.Runtime.Remoting.Messaging.StackBuilderSink.AsyncProcessMessage(IMessage msg, IMessageSink replySink) Exception rethrown at [1]: at System.Runtime.Remoting.Proxies.RealProxy.EndInvokeHelper(Message reqMsg, Boolean bProxyCase) at System.Runtime.Remoting.Proxies.RemotingProxy.Invoke(Object NotUsed, MessageData& msgData) at Microsoft.SharePoint.UserCode.SPUserCodeApplicationHostAppDomainRef.CodeToExecuteWrapper.EndInvoke(IAsyncResult result) at Microsoft.SharePoint.UserCode.SPUserCodeApplicationHostAppDomainRef.Execute(Type userCodeWrapperType, SPUserCodeCachedAssemblyGroup userAssemblyGroup, Guid siteCollectionId, Byte[] binaryUserCodeToken, Byte[] proxyOperationToken, SPUserCodeExecutionContext executionContext, Boolean shouldUsageLog, Int32 currentProcessId)
As i described, given template works only of top of a site collection, any other template (this is a custom one) works, even custom ones. Any ideas?
Edit:
This error is not reproducible, it happens only on 1 site collection with 1 particular template. It fails on activating one of the features, but when I created blank subsite and activated feature it failed on manually, it activated without any problems.