Cannot deactivate site template (solution) after creating and deleting a new site - sharepoint

In SharePoint 2010, I created a new site template from an existing site and a new site using this template. After deleting the new site and I cannot deactivate the site template to be able to remove it. Here's the exception I get:
System.ArgumentException: Value does not fall within the expected range.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Stack Trace:
[ArgumentException: Value does not fall within the expected range.]
Microsoft.SharePoint.SPWebCollection.get_Item(Guid id) +27763375
Microsoft.SharePoint.SPFeatureEnumeratorBase.GetCachedWeb(SPSite site, Guid webId, Guid featureId) +252
[SPFeatureIsOrphanedException: Unable to access web scoped feature (Id: 5c143ca0-e513-4fa5-93a6-a926352c982e) because it references a non-existent or broken web (Id: 196cdf6e-d4a1-4cb6-b962-591aaa3c5f43) on site 'http://win-9o8m2cks1v7'. Exception: System.ArgumentException: Value does not fall within the expected range.
at Microsoft.SharePoint.SPWebCollection.get_Item(Guid id)
at Microsoft.SharePoint.SPFeatureEnumeratorBase.GetCachedWeb(SPSite site, Guid webId, Guid featureId)]
Microsoft.SharePoint.SPFeatureEnumeratorBase.GetCachedWeb(SPSite site, Guid webId, Guid featureId) +22713369
Microsoft.SharePoint.SPFeatureEnumeratorBase.GetNextFeatureFromRowset(GetFeaturesState state, SqlDataReader reader, SPSite site) +464
Microsoft.SharePoint.SPSiteFeatureEnumerator.System.Collections.IEnumerator.MoveNext() +38
Microsoft.SharePoint.SPFeatureQueryResultCollection.System.Collections.IEnumerator.MoveNext() +26338677
Microsoft.SharePoint.SPUserSolutionCollection.RemoveFeatureInstancesAndDefinition(SPFeatureDefinition featdef) +770
Microsoft.SharePoint.SPUserSolutionCollection.Remove(SPUserSolution solution) +279
Microsoft.SharePoint.WebControls.SolutionItemButton.DeactivateItem() +464
Microsoft.SharePoint.WebControls.SPLinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +72
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +29
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2981
I already emptied the recyble bin. Does anybody know how can I deactivate and delete this site template?

You say that you have emptied the Recycle Bin. Are you certain you have emptied all the recycled items in BOTH recycle bins? If not, try this:
Go to the Site Settings page for the root web of your site collection. Under the heading Site Collection Administration, click the Recycle bin link. On the QuickLaunch menu, select End User Recycle Bin items, then select all the items that appear and click the Delete Selection link at the top of the items list. Now select Deleted From End User Recycle Bin from the QuickLaunch Menu and do the same.
Now return to the solution gallery and you should be able to deactivate and delete your solution.

Check your deactivation code. In there you have code that is causing this issue.
What I suggest is launch the features page, attach visual studio to all the w3wp processes and put a breakpoint in the feature deactivation. That should show you what is going wrong.
My guess is that you are creating a web object that no longer exists.

Related

Unable to rename subsite URL via CSOM in SharePoint Online

I have set up a SharePoint Online site and I have created a provider hosted app. One of the features of the app is to create subsites and there are times when a subsite needs to be renamed, including renaming the subsite URL. I can use the CSOM to create the subsite without any problems but when I try to rename the URL I get an access denied error. If I only change the title and description of the subsite there is no problem. If I log into SharePoint Online via the browser (using the same user account!) and I use the UI to rename the URL then it works without any problem. The page in SharePoint I use to rename the URL is https://tenant.sharepoint.com/testproject/_layouts/15/prjsetng.aspx
I have tried this on both a Microsoft 365 Developer subscription (where I am doing most of my development and testing) and the main SharePoint Online site where the solution will eventually be deployed to. I don't know much of the details for the main SPO site, other people set it up and I was provided an account to test renaming the subsite. To be clear, I am able to rename the subsite URL via the UI in both the developer and main SharePoint Online sites.
Is there something I'm doing wrong? Is there a limitation to renaming a subsite URL via code in SharePoint Online? Is there a bug in SharePoint Online that prevents renaming a subsite URL using code?
The exception thrown includes ServerErrorTypeName = "Microsoft.SharePoint.SPException". I can get the correlation id but from what I understand that's of no use in SharePoint Online. The exception Message is literally "Access denied." There is no inner exception.
Here is the code I'm using to rename the subsite:
SharePointContext spContext = SharePointContextProvider.Current.GetSharePointContext(HttpContext);
ClientContext clientContext = new ClientContext(spContext.SPHostUrl)
{
Credentials = new SharePointOnlineCredentials("SPUserName", "SPPassword".ToSecureString())
};
var webUrl = request.OldProjectUrl;
var subweb = clientContext.Site.OpenWeb(webUrl);
clientContext.Load(subweb);
clientContext.ExecuteQuery();
subweb.Title = request.ProjectName;
subweb.Description = request.ProjectName;
subweb.ServerRelativeUrl = "/HardcodedForTesting"; // <-- if I skip this line there is no error
subweb.Update();
clientContext.ExecuteQuery();
I was trying to achieve the same result but encountered the same error.
I was able to solve this by disabling the NoScriptSite setting of the site collection.
Using the PnP.PowerShell module:
Set-PnPSite -NoScriptSite:$false
Also the value you give to the ServerRelativeUrl property must be correctly constructed. I found two allowed format:
/sites/site-collection-path/new-subsite-path
new-subsite-path
Just did a test on my environment, I could rename the subsite URL via CSOM code normally. I use the same code as yours.
For your issue, you'd better create a service request with Microsoft.

System.UnauthorizedAccessException Access to the registry key

I have some code that calls the TFS API and returns team meta data. (e.g. team names, area paths, etc.) The code works fine locally in Visual Studio ASP.NET MVC project, but fails whenever I deploy to the server.
What I have tried that didn't work:
I granted the AppPool user account Full control to the registry key (did not work)
Also, tried granting Everyone Full Control to the registry key (still did not work)
Any insight into how to set up the correct permissions of configuration for IIS deployed apps to hit the TFS API would be greatly appreciated. (error message below)
Here's the Error message the app produces:
System.UnauthorizedAccessException
Access to the registry key 'HKEY_CURRENT_USER\Software\Microsoft\VSCommon\12.0\ClientServices\TokenStorage\VisualStudio' is denied.
System.UnauthorizedAccessException: Access to the registry key 'HKEY_CURRENT_USER\Software\Microsoft\VSCommon\12.0\ClientServices\TokenStorage\VisualStudio' is denied.
at Microsoft.Win32.RegistryKey.Win32Error(Int32 errorCode, String str)
at Microsoft.Win32.RegistryKey.CreateSubKeyInternal(String subkey, RegistryKeyPermissionCheck permissionCheck, Object registrySecurityObj, RegistryOptions registryOptions)
at Microsoft.Win32.RegistryKey.CreateSubKey(String subkey, RegistryKeyPermissionCheck permissionCheck, RegistryOptions options)
at Microsoft.VisualStudio.Services.Common.TokenStorage.RegistryTokenStorageHelper.GetRootKey(String subkeyName)
at Microsoft.VisualStudio.Services.Common.TokenStorage.RegistryTokenStorage.RetrieveToken(VssTokenKey tokenKey)
at Microsoft.TeamFoundation.Client.TfsClientCredentialStorage.RetrieveToken(Uri serverUrl, VssCredentialsType credentialType)
at Microsoft.TeamFoundation.Client.CookieCredential.OnCreateTokenProvider(Uri serverUrl, HttpWebResponse response)
at Microsoft.TeamFoundation.Client.IssuedTokenCredential.CreateTokenProvider(Uri serverUrl, HttpWebResponse response, IssuedToken failedToken)
at Microsoft.TeamFoundation.Client.TfsClientCredentials.TryGetTokenProvider(Uri serverUrl, IssuedTokenProvider& provider)
at Microsoft.TeamFoundation.Client.Channels.TfsHttpRequestHelpers.PrepareWebRequest(HttpWebRequest webRequest, Guid sessionId, String operationName, CultureInfo cultureInfo, TfsRequestSettings settings, TfsClientCredentials credentials, IdentityDescriptor impersonate, IssuedToken& currentToken, IssuedTokenProvider& tokenProvider)
at Microsoft.TeamFoundation.Client.Channels.TfsHttpRequestHelpers.CreateSoapRequest(Uri requestUri, Guid sessionId, String soapAction, String operationName, CultureInfo cultureInfo, TfsRequestSettings settings, TfsClientCredentials credentials, IdentityDescriptor impersonate, IssuedToken& currentToken, IssuedTokenProvider& tokenProvider)
at Microsoft.TeamFoundation.Client.Channels.TfsHttpWebRequest.CreateWebRequest()
at Microsoft.TeamFoundation.Client.Channels.TfsHttpWebRequest.SendRequest()
at Microsoft.TeamFoundation.Client.Channels.TfsHttpRequestChannel.Request(TfsMessage message, TimeSpan timeout)
at Microsoft.TeamFoundation.Client.Channels.TfsHttpClientBase.Invoke(TfsClientOperation operation, Object[] parameters, TimeSpan timeout, Object[]& outputs)
at Microsoft.TeamFoundation.Framework.Client.RegistrationProxy.GetRegistrationEntries(String toolId)
at Microsoft.TeamFoundation.Framework.Client.RegistrationService.RefreshMemoryCache()
at Microsoft.TeamFoundation.Framework.Client.RegistrationService.Microsoft.TeamFoundation.Server.IRegistration.GetRegistrationEntries(String toolId)
at Microsoft.TeamFoundation.Framework.Client.IdentityManagementService..ctor(TfsConnection tfsBase)
at Microsoft.TeamFoundation.Framework.Client.IdentityManagementService2..ctor(TfsConnection tfsBase)
at Microsoft.TeamFoundation.Client.TfsConnection.CreateInternalProxy(Type serviceType)
at Microsoft.TeamFoundation.Client.TfsConnection.GetServiceInstance(Type serviceType, Object serviceInstance)
at Microsoft.TeamFoundation.Client.TfsConnection.GetService(Type serviceType)
at Microsoft.TeamFoundation.Client.TfsConnection.GetService[T]()
at Microsoft.TeamFoundation.Client.TfsTeamService.QueryTeams(String projectId)
I have been having the same problem and have solved it by setting the "Load User Profile" in IIS application pool settings to True.
I don't know if this is some new dependency in TFS 2013 or whether IIS 8.5 has changed the default, but this fixes it for me.
I ran into this same issue, but setting Load User Profile to TRUE didn't work for me. What did eventually work was going into the registry and adding a "HKCU\Software\Microsoft\VSCommon\12.0\ClientServices" key for the appropriate user(s). Apparently the TFS assemblies get a little cranky when you try to use them on systems without Visual Studio installed on them.
Credit goes to whoever added this information to http://msdn.developer-works.com/article/12173562/After+upgrade+from+TFS+2010+to+TFS+2013+the+soap+notifications+stop+working.
We had this issue and setting the "Load User Profile" in IIS application pool settings to True worked for us. But then the same issue came back and we found setting "Load User Profile" in IIS application pool settings to False fixed the issue once again. So it appears to me that it is the toggling of this setting that is fixing something rather than the actual value it is set to. No matter what "Load User Profile" in IIS application pool is set to, I would try toggling it to the opposite value, refresh the application pool and see if that helps. If anyone tracks down the root cause of this please share.

After migration to sharepoint 2010 search result error Cannot find ContentPlaceHolder 'SPNavigation'

I am migrating MOSS 2007 portal to sahrepoint 2010. I am not doing visual uplgrade. to check search setting i typed a keyword and pressed enter anfd it threw me below error. please let me know what to do as I am completely new in this.
Do I need to add the "SPNavigaation" placeholder in my master page. I dont know what custom.master page it is refering.
Error:
Server Error in '/' Application.
Cannot find ContentPlaceHolder 'SPNavigation' in the master page '~masterurl/custom.master', verify content control's ContentPlaceHolderID attribute in the content page.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: Cannot find ContentPlaceHolder 'SPNavigation' in the master page '~masterurl/custom.master', verify content control's ContentPlaceHolderID attribute in the content page.
Dear all I solved the issue by adding "
<asp:ContentPlaceHolder ID="SPNavigation" runat="server"></asp:ContentPlaceHolder>
"in my master page

Sharepoint Crawler is denied access to sites

We create all our site collections programatically with a custom site def/template. Everything works as expected, except for the crawler. It's apparently denied access to the sites. The crawl logs says:
http://server.localnetwork.lan/somesites/siteName
The object was not found. (The item
was deleted because it was either not
found or the crawler was denied access
to it.)
And in the log files I'm getting this:
08/11/2009 14:20:34.01 OWSTIMER.EXE
(0x0674)
0x1560 Search Server Common
MS Search Administration
7hmh High exception in
SearchUpgradeProvisioner Keyword
Config
System.InvalidOperationException:
jobServerSearchServiceInstance is null
at
Microsoft.Office.Server.Search.Administration.SearchUpgradeProvisioner..ctor(SearchServiceInstance
searchServiceInstance) at
Microsoft.Office.Server.Search.Administration.OSSPrimaryGathererProject.ProvisionContentSources()
If I create a site collection manually the crawler is able to access it. The same users/accounts have the same access on both sites, so that shouldn't be the issue.
The code we use to actually create the site collection looks a little like this:
SPWebApplication app = SPWebApplication.Lookup(new Uri("WebApplicationUrl"));
app.FormDigestSettings.Enabled = false;
app.Sites.Add("url", "title", "description", "language code", "SiteTemplateName", "Owner.Username", "Owner.Fullname", "Owner.Email");
app.FormDigestSettings.Enabled = true;
The code has been slightly altered to protect the innocent... ;)
Any idea what we're doing wrong?
(Please note, I'm not sure if this is a programming error or a config/setup error, so I'm cross-posting with Serverfault)
If you receive this error whilst the crawler account (the default content access account) has read permission to all your sites then you most likely need to disable the loopback check.
http://support.microsoft.com/kb/896861
http://koenvosters.wordpress.com/2009/06/15/access-denied-when-using-hostname-search-and-site-on-moss-2007/

SharePoint QuickLaunch and TopNavigationBar dissapearing

I am completely puzzled with this:
I have a custom SharePoint site with QuickLaunch on the left and Top Navigation Bar (which are of course visible by default).
This custom site has several sub-sites, which all inherit navigation from the root site.
Everything works fine, but after application pool recycle both menus on the left and on top are disappearing when I enter any of the sites for the first time! After simple refresh everything is back to normal, all menus are visible.
After recreating the site and subsites they behave the same: on first visit - menus are not visible, after refresh they are visible and they stay visible until I make an application pool recycle.
Sometimes only one menu (top bar or quick launch) disappears and the second one is normally visible, and I also think I encountered a situation when it disappeared during normal using of the site, not after the recycle.
There is nothing in the EventLog. There is a trace in the ULS log, though. When quick launch or top bar disappears only one new line (yes, only this one, no stack trace or any further information) is added:
02/05/2010 10:24:19.18 w3wp.exe (0x171C) 0x17BC Windows SharePoint Services General 8kh7 High Cannot complete this action. Try again.
Well, indeed it says that something is wrong that is causing the menu to disappear. Can anyone help me how to diagnose this or maybe knows why these menus are disappearing?
Gylo do you have the Publishing feature enabled on those sites? This is a known situation when restoring saved site templates with publishing enabled (using a small hack) where the Top Navigation won't appear for the first time.
What version are you running? (Site Actions => Site Definitions shows it)
It may be that you messed with Navigation in site definition and removed Navigation Node with Id of 1002. This node is responsible for storing web Top Navigation, and even if your web uses shared navigation, you'll get disappearing navigation under some circumstances.
Check if your-web.Navigation.TopNavigationBar is null. If it is, that is not very simple to restore node #1002. Below is a patch I've written to fix this issue on production environment. Test it first!
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
SPSite site = properties.Feature.Parent as SPSite;
using (SPWeb web = site.OpenWeb("/information"))
{
if (web.Navigation.TopNavigationBar == null)
{
List<SPContentDatabase> contentdatabases = new List<SPContentDatabase>();
SPSecurity.RunWithElevatedPrivileges(delegate()
{
SPNavigationNode node = new SPNavigationNode("", web.ServerRelativeUrl, false);
web.AllowUnsafeUpdates = true;
try
{
SPNavigationNodeCollection navigationNodes = null;
navigationNodes = web.Navigation.GlobalNodes;
navigationNodes.AddAsFirst(node);
}
finally
{
web.AllowUnsafeUpdates = false;
}
SPContentDatabase database = site.ContentDatabase;
using (SqlConnection con = new SqlConnection(database.DatabaseConnectionString))
{
con.Open();
using (SqlCommand command = con.CreateCommand())
{
command.CommandText = string.Format(#"UPDATE NavNodes
SET Url='', Eid={0}, ElementType=1, DocId=NULL
WHERE Eid={1}
and WebId='{2}'
and SiteId='{3}'",
1002,
node.Id,
web.ID.ToString(),
site.ID.ToString()
);
command.ExecuteNonQuery();
}
}
});
}
}
}

Resources