I have created a Sandbox-solution With a List Event Receiver. When a New item is added to the list, a Workspace should be created based on a sitetemplate.
Code in my latest attemp;
wWeb.AllowUnsafeUpdates = true;
newWeb = wWeb.Webs.Add(properties.ListItem[numb].ToString(), properties.ListItem[numb].ToString() + " " + properties.ListItem["Title"].ToString(), "", 1044, arbeidsrommal, false, false);
wWeb.Update();
wWeb.AllowUnsafeUpdates = false;
this work for 4 list items, sites wore created. But 1h later when i tried it casted a error for all items i created:
at Microsoft.SharePoint.Library.SPRequestInternalClass.CreateWeb(String bstrUrl, String bstrTitle, String bstrDescription, UInt32 nLCID, Boolean bCreateUniqueWeb, Guid& pguidAppInstanceId, String bstrAppWebDomainId, Boolean bConvertIfThere, Guid& pgWebId, Guid& pgRootFolderId, Boolean bCreateSystemCatalogs)
at Microsoft.SharePoint.Library.SPRequest.CreateWeb(String bstrUrl, String bstrTitle, String bstrDescription, UInt32 nLCID, Boolean bCreateUniqueWeb, Guid& pguidAppInstanceId, String bstrAppWebDomainId, Boolean bConvertIfThere, Guid& pgWebId, Guid& pgRootFolderId, Boolean bCreateSystemCatalogs)
--- End of inner exception stack trace ---
Server stack trace:
at Microsoft.SharePoint.SPGlobal.HandleComException(COMException comEx)
at Microsoft.SharePoint.Library.SPRequest.CreateWeb(String bstrUrl, String bstrTitle, String bstrDescription, UInt32 nLCID, Boolean bCreateUniqueWeb, Guid& pguidAppInstanceId, String bstrAppWebDomainId, Boolean bConvertIfThere, Guid& pgWebId, Guid& pgRootFolderId, Boolean bCreateSystemCatalogs)
at Microsoft.SharePoint.SPWeb.CreateWeb(String strWebUrl, String strTitle, String strDescription, UInt32 nLCID, String strWebTemplate, Boolean bCreateUniqueSubweb, Boolean bConvertIfThere, Guid appInstanceId)
at Microsoft.SharePoint.SPWeb.SPWebCollectionProvider.CreateWeb(String strWebUrl, String strTitle, String strDescription, UInt32 nLCID, String strWebTemplate, Boolean bCreateUniqueSubweb, Boolean bConvertIfThere, Guid appInstanceId)
at Microsoft.SharePoint.SPWebCollection.Add(String strWebUrl, String strTitle, String strDescription, UInt32 nLCID, String strWebTemplate, Boolean useUniquePermissions, Boolean bConvertIfThere, Guid appInstanceId)
at Microsoft.SharePoint.SPWebCollection_SubsetProxy.Add__Inner(String strWebUrl, String strTitle, String strDescription, UInt32 nLCID, SPWebTemplate_SubsetProxy WebTemplate, Boolean useUniquePermissions, Boolean bConvertIfThere)
at Microsoft.SharePoint.SPWebCollection_SubsetProxy.Add(String strWebUrl, String strTitle, String strDescription, UInt32 nLCID, SPWebTemplate_SubsetProxy WebTemplate, Boolean useUniquePermissions, Boolean bConvertIfThere)
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)
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.SPWebCollection_SubsetProxy.Add(String strWebUrl, String strTitle, String strDescription, UInt32 nLCID, SPWebTemplate_SubsetProxy WebTemplate, Boolean useUniquePermissions, Boolean bConvertIfThere)
at Microsoft.SharePoint.SPWebCollection.Add__Inner(String strWebUrl, String strTitle, String strDescription, UInt32 nLCID, SPWebTemplate WebTemplate, Boolean useUniquePermissions, Boolean bConvertIfThere)
at Microsoft.SharePoint.SPWebCollection.Add(String strWebUrl, String strTitle, String strDescription, UInt32 nLCID, SPWebTemplate WebTemplate, Boolean useUniquePermissions, Boolean bConvertIfThere)
at O365.XproAS.ProjectLogEvents.ProjectLogEvents.CreatedWorkspace(SPItemEventProperties properties)
I also tried a Version where i checked if the web was actual in use;
SPWeb newWeb = null;
//foreach (SPWeb subWeb in wWeb.Webs)
//{
// if (subWeb.Name == properties.ListItem[numb].ToString())
// newWeb = subWeb;
//}
but it just gave me the same error.
What can be wrong?
br. Heggdal
Heggdal!