Walkaround for common “TaxonomyPicker.ascx” error in Windows Event Log: SharePoint Feature that renames the file

There is a common error in SharePoint 2010: On almost every (web frontend) server you can find this error in the Windows Event Log “Application”:

Event Type: Error
Event Source: SharePoint Foundation
Event Category: None
Event ID: 7043
Computer: SERVERNAME
Description: Load control template file /_controltemplates/TaxonomyPicker.ascx failed: Could not load type ‘Microsoft.SharePoint.Portal.WebControls.TaxonomyPicker’ from assembly ‘Microsoft.SharePoint.Portal, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c’.

image

The problem is described in many blogs and sites, e.g.:

To solve the problem there’s no other way than renaming the “TaxonomyPicker.ascx” file.

On a single-server farm it’s not that problem but in a huge farm with about 100 servers … ?

I’ve created simple SharePoint 2010 solution that will do the job for you.

The solution deploys a SharePoint Timer Job Definition and the farm feature event receiver creates two timer jobs for every web application on the system. The first timer job is a “one-time” job, the other one is a “daily” job. Each job checks the SharePoint hive on the local disk of every server and renames the “TaxonomyPicker.ascx” file to “TaxonomyPicker.ascx.disabled”, if the file is present. If the file “TaxonomyPicker.ascx” not present or already renamed it does nothing.

the “one-time” job runs some seconds after the feature activation and will delete itself after running. The “daily” job executes every day between 1am and 2am.

You can download this code at Codeplex. Please feel free to modify it, but please send me your improvements or request “edit” permissions on codeplex. – I’m sure there are possible improvements. It’s a “quick dev project”.

http://spdisabletaxpicker.codeplex.com/

When you disable the farm feature the file “TaxonomyPicker.ascx.disabled” is renamed back to “TaxonomyPicker.ascx”!

Be sure you test the feature in a dev system before you use it in a live system!!!! I only provide the source code he. Please compile it by yourself und use the solution as you want.

BTW: A little trick for development in Visual Studio 2010 – Start PowerShell scripts that need to run in an x64 context by double click from Solution Explorer

For development and some related tasks I use PowerShell, of course. – I store the PowerShell scripts in my projects as part of them. They are part of the source code and they are saved in the source control.

If I need to run such a script I start it directly from Solution Explorer in VS2010.

Therefore I’ve set the default “open with…” to “powershell.exe”

image

image

image

If you have done this you can run every “.ps1” script file by double click in Solution Explorer!!

BUT… VS2010 itself is 32bit! – If you start an architecture independend process like “poweshell.exe” from within VS2010 it runs in 32bit environment! But sometimes you need to run a 64 version of PowerShell, e.g. for some SharePoint tasks that need an 64 bit environment.

Therefore I’ve created a little App “StartPS64”:

1. In VS2010 create a new Project of type “Console Application”

2. Open the project’s properties, select the “Build” tab and change “Platform target” to x64.

SNAGHTML57d9e4d

3. Edit “program.cs” and insert this code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace StartPS64
{
    class Program
    {
        static void Main(string[] args)
        {
            string fullname = System.IO.Path.GetFullPath(args[0]);
            if( !System.IO.File.Exists(fullname) )
            {
                Console.WriteLine("Script does not exist!");
                Console.ReadKey();
                return;
            }

            Process.Start(@"c:windowssystem32windowspowershellv1.0powershell.exe", fullname);
        }
    }
}

4. Compile it.

5. Specify the build “startps64.exe” as new “default application” for “.ps1” files in VS2010 as described above.

6. Now every “.ps1” file started from the Solution Explorer will run in an 64 bit environment and can execute SharePoint cmdlets!

Walkaround for problems accessing a diffrent web by “Linq to SharePoint” inside server code.

At the weekend I tried to access a diffrent SharePoint Web (SPWeb) from inside server code (ASPX application page).

Before I created interface classes to the “diffrent SharePoint Web” by using SPMetal.

In the server side code I used this snipped to access the “diffrent SharePoint Web” by using the generated interface:

using System;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;

namespace myProject
{
public partial class ManageFeature : LayoutsPageBase
{
protected void Page_Load(object sender, EventArgs e)
{

string diffrentWebUrl = “http://diffrentWebUrl”;
using( DiffrentWebDataContext dc = new DiffrentWebDataContext(diffrentWebUrl) )
{
var x1 = from x in dc.ListOnDiffrentWeb
                             select x;
var x2 = x1.ToList();
}
}
}
}

This failed because inside server code you cannot access a diffrent Web by using Linq to SharePoint.

Read this blog post Chun Liu:

http://blogs.msdn.com/b/chunliu/archive/2010/04/17/linq-to-sharepoint-query-across-site-collections.aspx

Here is a suggestion how to solve this by Pascal Be:

http://social.technet.microsoft.com/Forums/sv-SE/sharepoint2010programming/thread/715ddcbb-619d-4688-8d99-d7a6aa078307

I’ve created a helper class for this workaround:

using System;
using System.IO;
using System.Web;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;

namespace ik.SharePoint2010
{
    public class CustomSPContext : IDisposable {
        private HttpContext originalContext;

        public static CustomSPContext CreateSPCustomContext(SPWeb contextWeb)
        {
            return new CustomSPContext(contextWeb);
        }

        private CustomSPContext(SPWeb contextWeb)
        {
            originalContext = HttpContext.Current;

            string url = contextWeb.Url;
            HttpRequest httpRequest = new HttpRequest("", url, "");
            HttpContext.Current = new HttpContext(httpRequest, new HttpResponse(new StringWriter()));
            SPControl.SetContextWeb(HttpContext.Current, contextWeb);
        }

        public void Dispose()
        {
            HttpContext.Current = originalContext;
        }
    }
}

 

You can use it like this:

using System;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;

namespace kc.GlobalNotification
{
    public partial class ManageFeature : LayoutsPageBase {
        protected void Page_Load(object sender, EventArgs e)
        {
            string diffrentWebUrl = "http://diffrentWebUrl";

            using( var site = new SPSite(diffrentWebUrl) )
            {
                using( var web = new SPWeb(diffrentWebUrl) )
                {
                    using( ik.SharePoint2010.CustomSPContext.CreateSPCustomContext(web) )
                    {

using( DiffrentWebDataContext dc = new DiffrentWebDataContext(diffrentWebUrl) ){

                           var x1 = from x in dc.ListOnDiffrentWeb
                                    select x;
                           var x2 = x1.ToList();

}

                    }
                }
            }
        }
    }
}

Walkthrough: Create simple WCF Web Service for SharePoint 2010 with Visual Studio 2010

In this “Walkthrough” I’d like to show you how to create a simple WCF Web Service for SharePoint 2010.

This Web Service will provide two methods:

  • Ping => Just as test.
  • GetUsedEmailAliasses => This method reports all aliasses used for “E-Mail enabled lists” in SharePoint.

Here is the code: http://spwcfwebservicedemo.codeplex.com/

Let’s start.

1. Create a new SharePoint 2010 project in Visual Studio 2010. Use the “Empty Project” template. Name the project “ik.SharePoint2010.SPWCFWebServiceDemo”.

image

2. In the project creation wizard specify the Central Administration address as deployment location. You need to deploy as “Farm Solution”:

image

3. Now add this Assembly References:

  • Microsoft.SharePoint.Client
  • Microsoft.SharePoint.Client.Runtime
  • Microsoft.SharePoint.Client.ServerRuntime
    (You may need to locate this assembly in the file system: “C:WindowsassemblyGAC_MSILMicrosoft.SharePoint.Client.ServerRuntime14.0.0.0__71e9bce111e9429cMicrosoft.SharePoint.Client.ServerRuntime.dll”)
  • System.Configuration
  • System.ServiceModel
  • System.ServiceModel.Web

Now my Assembly Reference tree looks like this:

4. Now map the SharePoint hive folder “Layouts” to your project:

a) Right click your project in the Solution Explorer Pane

b) In the context menu open sub menu “Add” and click “SharePoint Mapped Folder”

c) Select this:

image

d) Click “OK”

5. Create a sub folder named “ik.SharePoint2010.SPWCFWebServiceDemo” in folder “Layouts”

6. Add a new project item of type “Interface” to your project. Name it “ISPWCFSvc.cs”.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Runtime.InteropServices;
using System.ServiceModel;
using System.ServiceModel.Web;

namespace ik.SharePoint2010.SPWCFWebServiceDemo
{
    [ServiceContract(Namespace="http://schemas.microsoft.com/sharepoint/soap/"),      Guid("f01e2ff6-c291-4b8b-a154-cd7059ed4900")]
    public interface ISPWCFSvc  {
        [OperationContract, WebInvoke(Method = "GET")]
        List<string> GetUsedEmailAliasses();

        [OperationContract, WebInvoke(Method = "GET")]
        string Ping();
    }
}
7. Add a new project item of type “Class” and name it “SPWCFSvc.cs”
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Security.Permissions;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.Web;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;
using Microsoft.SharePoint.Client;
using Microsoft.SharePoint.Security;

namespace ik.SharePoint2010.SPWCFWebServiceDemo
{
    [Guid("ae428eb5-02d1-4e50-8cee-eb3806f16ffd"),
    ServiceBehavior(Namespace = "http://schemas.microsoft.com/sharepoint/soap/"),
    AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required),
    ClientRequestServiceBehavior,
    SharePointPermission(SecurityAction.Demand, ObjectModel = true),
    AspNetHostingPermission(SecurityAction.Demand, Level = AspNetHostingPermissionLevel.Minimal)]
    public class SPWCFSvc : ISPWCFSvc  {
        [SharePointPermission(SecurityAction.Demand, ObjectModel = true)]
        public List<string> GetUsedEmailAliasses()
        {
            List<string> l = new List<string>();

            SPProcessIdentity pi = SPContext.Current.Site.WebApplication.Farm.TimerService.ProcessIdentity;
            string userName = pi.Username;
            object configDB = pi.GetType().GetProperty("ConfigurationDatabase", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(pi, null);
            SPServer server = (SPServer)configDB.GetType().GetProperty("Server").GetValue(configDB, null);
            string dbName = (string)configDB.GetType().GetProperty("Name").GetValue(configDB, null);
            string serverName = server.Name;

            SPSecurity.RunWithElevatedPrivileges(() =>
            {
                System.Data.SqlClient.SqlConnection s = new System.Data.SqlClient.SqlConnection(new System.Data.SqlClient.SqlConnectionStringBuilder {
                    DataSource = serverName,
                    InitialCatalog = dbName,
                    IntegratedSecurity = true }.ConnectionString);

                SPConfigDBDataContext dc = new SPConfigDBDataContext(s);

                foreach( var item in dc.EmailEnabledLists )
                {
                    l.Add(item.Alias);
                }
            });

            return l;
        }

        [SharePointPermission(SecurityAction.Demand, ObjectModel = true)]
        public string Ping()
        {
            return "Pong";
        }
    }
}
8. Now add a new “Text File” project item and name it “spwcfsvc.svc”
<% @ServiceHost Service="$SharePoint.Type.ae428eb5-02d1-4e50-8cee-eb3806f16ffd.AssemblyQualifiedName$" Factory="Microsoft.SharePoint.Client.Services.MultipleBaseAddressWebServiceHostFactory, Microsoft.SharePoint.Client.ServerRuntime, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"%>

Here we use an existing service factory of SharePoint that will handle the service instanciation for us.

In this file we use the token replacement functionality of Visual Studio 2010 for SharePoint 2010 development. We like to replace the token “$SharePoint.Type.ae428eb5-02d1-4e50-8cee-eb3806f16ffd.AssemblyQualifiedName$” through the “real” full qualified name during package creation.

By default *.svc files will not be processed by the token replacement engine. We need to specify *.svc files for that build step. Therefore we edit the C# project file in notepad.  Insert this line as shown in the screenshot:

<TokenReplacementFileExtensions>svc</TokenReplacementFileExtensions>

image

After deploying the solution you may have a look into the SharePoint hive and look into “spwcfsvc.svc”

9. Now Copy & Paste this file into the you folder in the mapped Layouts folder:

C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions14ISAPIweb.config

10. You need to edit this file. Remove the complete “<system.web>” tag and the (four) “location” tags at the beginning of the copied file! – The configuration settings in the copied & modified web.config file will manage the diffrent authentication methods for us. This works by using the class attribute “ClientRequestServiceBehavior” in the code above.

11. Now we add a “Linq to SQL” connection to the SharePoint Configuration database. Be sure only to read this DB!!!

12. Add a new project item of type “Linq to SQL Classes” to the project. Name it “SPConfigDB.dbml”

image

13. In the Server Explorer of Visual Studio 2010 create a connection to the SharePoint Configuration DB of your development environment. – After that, open the connection, open the “Table” node and select “EmailEnabledLists”.

image

14. Drag the “EmailEnabledLists” node to the “SPConfigDB.dbml” canvas. – It looks like this:

image

15. In the Properties Pane set the “Context Namespace” property to “ik.SharePoint2010.SPWCFWebServiceDemo”. (If you do not see this properties like in the screenshot below you need to right click the “SPConfigDB.dbml” project item node in the Solution explorer and click “Properties” in the context menu.

image

16. Now you should be able to compile and deploy your project.

17. Edit the startup settings. In the “Debug” select “Start browser with URL” and enter there the URL to your webservice: “http://<central-administration-url-and-port>/_layouts/ik.sharepoint2010.spwcfwebservicedemo/spwcf.svc/GetUsedEmailAliasses”

SNAGHTML4b070d4

18. Now start the project. You get something like this:

SNAGHTML4acbe57

I’ve only one e-mail enabled list or library in my current dev system.

Migration Issue – Error in Upgrade Log: “Exception thrown while applying the global template to the web with URL “(unknown)” (Id: ”) from site with URL “(unknown)” (Id: ”). Adding web to the exceptions list. Exception: System.IO.FileNotFoundException: The site with the id could not be found.”

In my curent migration project I got this error in an Content Database upgrade log on the new SharePoint 2010 farm:

Template MPS#0: Exception thrown while applying the global template to the web with URL “(unknown)” (Id: ‘a98475b1-385d-4ac6-bc1b-226f2e35a27e’) from site with URL “(unknown)” (Id: ‘3e800bc3-296f-47f0-a04d-b1e4ae385cb8’). Adding web to the exceptions list. Exception: System.IO.FileNotFoundException: The site with the id 3e800bc3-296f-47f0-a04d-b1e4ae385cb8 could not be found.

Template <templateId>: Exception thrown while applying the global template to the web with URL “(unknown)” (Id: ‘<guid>‘) from site with URL “(unknown)” (Id: ‘<guid>’). Adding web to the exceptions list. Exception: System.IO.FileNotFoundException: The site with the id <guid> could not be found.

This is a piece of text of the upgrade log file:

 
[ScriptEditor] [SPWebTemplateSequence] [DEBUG] [12/8/2011 7:04:24 PM]: Template MPS#0: Exception thrown while applying the global template to the web with URL "(unknown)" (Id: 'e5c2cec5-7d3a-483b-ac55-0ca60a7ba432') from site with URL "(unknown)" (Id: '3e800bc3-296f-47f0-a04d-b1e4ae385cb8'). Adding web to the exceptions list. Exception: System.IO.FileNotFoundException: The site with the id 3e800bc3-296f-47f0-a04d-b1e4ae385cb8 could not be found.
   at Microsoft.SharePoint.SPSite..ctor(Guid id, SPFarm farm, SPUrlZone zone, SPUserToken userToken)
   at Microsoft.SharePoint.SPSite..ctor(Guid id)
   at Microsoft.SharePoint.Upgrade.SPWebTemplateSequence.ApplyGlobalTemplateToWebs(List`1 lstwebinfoToUpgrade, List`1& lstwebinfoExceptions)
[ScriptEditor] [SPWebTemplateSequence] [DEBUG] [12/8/2011 7:04:24 PM]: Template MPS#0: Exception thrown while applying the global template to the web with URL "(unknown)" (Id: 'a98475b1-385d-4ac6-bc1b-226f2e35a27e') from site with URL "(unknown)" (Id: '3e800bc3-296f-47f0-a04d-b1e4ae385cb8'). Adding web to the exceptions list. Exception: System.IO.FileNotFoundException: The site with the id 3e800bc3-296f-47f0-a04d-b1e4ae385cb8 could not be found.
   at Microsoft.SharePoint.SPSite..ctor(Guid id, SPFarm farm, SPUrlZone zone, SPUserToken userToken)
   at Microsoft.SharePoint.SPSite..ctor(Guid id)
   at Microsoft.SharePoint.Upgrade.SPWebTemplateSequence.ApplyGlobalTemplateToWebs(List`1 lstwebinfoToUpgrade, List`1& lstwebinfoExceptions)
[ScriptEditor] [SPWebTemplateSequence] [DEBUG] [12/8/2011 7:04:24 PM]: Template MPS#0: Exception thrown while applying the global template to the web with URL "(unknown)" (Id: '71f74b12-8ba9-4483-8554-38894878a620') from site with URL "(unknown)" (Id: '3e800bc3-296f-47f0-a04d-b1e4ae385cb8'). Adding web to the exceptions list. Exception: System.IO.FileNotFoundException: The site with the id 3e800bc3-296f-47f0-a04d-b1e4ae385cb8 could not be found.
   at Microsoft.SharePoint.SPSite..ctor(Guid id, SPFarm farm, SPUrlZone zone, SPUserToken userToken)
   at Microsoft.SharePoint.SPSite..ctor(Guid id)
   at Microsoft.SharePoint.Upgrade.SPWebTemplateSequence.ApplyGlobalTemplateToWebs(List`1 lstwebinfoToUpgrade, List`1& lstwebinfoExceptions)
[ScriptEditor] [SPWebTemplateSequence] [DEBUG] [12/8/2011 7:04:24 PM]: Template MPS#0: Exception thrown while applying the global template to the web with URL "(unknown)" (Id: '48b3e9f9-e9fa-4981-93ce-3dec85dc3ee7') from site with URL "(unknown)" (Id: '3e800bc3-296f-47f0-a04d-b1e4ae385cb8'). Adding web to the exceptions list. Exception: System.IO.FileNotFoundException: The site with the id 3e800bc3-296f-47f0-a04d-b1e4ae385cb8 could not be found.
   at Microsoft.SharePoint.SPSite..ctor(Guid id, SPFarm farm, SPUrlZone zone, SPUserToken userToken)
   at Microsoft.SharePoint.SPSite..ctor(Guid id)
   at Microsoft.SharePoint.Upgrade.SPWebTemplateSequence.ApplyGlobalTemplateToWebs(List`1 lstwebinfoToUpgrade, List`1& lstwebinfoExceptions)
[ScriptEditor] [SPWebTemplateSequence] [DEBUG] [12/8/2011 7:04:24 PM]: Template MPS#0: Exception thrown while applying the global template to the web with URL "(unknown)" (Id: '75ddba70-768c-435e-96a1-4491c61083b6') from site with URL "(unknown)" (Id: '3e800bc3-296f-47f0-a04d-b1e4ae385cb8'). Adding web to the exceptions list. Exception: System.IO.FileNotFoundException: The site with the id 3e800bc3-296f-47f0-a04d-b1e4ae385cb8 could not be found.
   at Microsoft.SharePoint.SPSite..ctor(Guid id, SPFarm farm, SPUrlZone zone, SPUserToken userToken)
   at Microsoft.SharePoint.SPSite..ctor(Guid id)
   at Microsoft.SharePoint.Upgrade.SPWebTemplateSequence.ApplyGlobalTemplateToWebs(List`1 lstwebinfoToUpgrade, List`1& lstwebinfoExceptions)
[ScriptEditor] [SPWebTemplateSequence] [DEBUG] [12/8/2011 7:04:24 PM]: Template MPS#0: Exception thrown while applying the global template to the web with URL "(unknown)" (Id: 'ebb027c8-56ec-4526-9962-514ef0b33f7a') from site with URL "(unknown)" (Id: '3e800bc3-296f-47f0-a04d-b1e4ae385cb8'). Adding web to the exceptions list. Exception: System.IO.FileNotFoundException: The site with the id 3e800bc3-296f-47f0-a04d-b1e4ae385cb8 could not be found.
   at Microsoft.SharePoint.SPSite..ctor(Guid id, SPFarm farm, SPUrlZone zone, SPUserToken userToken)
   at Microsoft.SharePoint.SPSite..ctor(Guid id)
   at Microsoft.SharePoint.Upgrade.SPWebTemplateSequence.ApplyGlobalTemplateToWebs(List`1 lstwebinfoToUpgrade, List`1& lstwebinfoExceptions)
[ScriptEditor] [SPWebTemplateSequence] [DEBUG] [12/8/2011 7:04:24 PM]: Template MPS#0: Exception thrown while applying the global template to the web with URL "(unknown)" (Id: 'bedbd386-98cd-4070-ab96-6dc5a58c2908') from site with URL "(unknown)" (Id: '3e800bc3-296f-47f0-a04d-b1e4ae385cb8'). Adding web to the exceptions list. Exception: System.IO.FileNotFoundException: The site with the id 3e800bc3-296f-47f0-a04d-b1e4ae385cb8 could not be found.
   at Microsoft.SharePoint.SPSite..ctor(Guid id, SPFarm farm, SPUrlZone zone, SPUserToken userToken)
   at Microsoft.SharePoint.SPSite..ctor(Guid id)
   at Microsoft.SharePoint.Upgrade.SPWebTemplateSequence.ApplyGlobalTemplateToWebs(List`1 lstwebinfoToUpgrade, List`1& lstwebinfoExceptions)
[ScriptEditor] [SPWebTemplateSequence] [DEBUG] [12/8/2011 7:04:24 PM]: Template MPS#0: Exception thrown while applying the global template to the web with URL "(unknown)" (Id: '22a173d5-68e3-40a4-b749-71f5c26a57d7') from site with URL "(unknown)" (Id: '3e800bc3-296f-47f0-a04d-b1e4ae385cb8'). Adding web to the exceptions list. Exception: System.IO.FileNotFoundException: The site with the id 3e800bc3-296f-47f0-a04d-b1e4ae385cb8 could not be found.
   at Microsoft.SharePoint.SPSite..ctor(Guid id, SPFarm farm, SPUrlZone zone, SPUserToken userToken)
   at Microsoft.SharePoint.SPSite..ctor(Guid id)
   at Microsoft.SharePoint.Upgrade.SPWebTemplateSequence.ApplyGlobalTemplateToWebs(List`1 lstwebinfoToUpgrade, List`1& lstwebinfoExceptions)
[ScriptEditor] [SPWebTemplateSequence] [DEBUG] [12/8/2011 7:04:24 PM]: Template MPS#0: Exception thrown while applying the global template to the web with URL "(unknown)" (Id: 'b4e93fdf-9412-44ad-9402-77f215534d88') from site with URL "(unknown)" (Id: '3e800bc3-296f-47f0-a04d-b1e4ae385cb8'). Adding web to the exceptions list. Exception: System.IO.FileNotFoundException: The site with the id 3e800bc3-296f-47f0-a04d-b1e4ae385cb8 could not be found.
   at Microsoft.SharePoint.SPSite..ctor(Guid id, SPFarm farm, SPUrlZone zone, SPUserToken userToken)
   at Microsoft.SharePoint.SPSite..ctor(Guid id)
   at Microsoft.SharePoint.Upgrade.SPWebTemplateSequence.ApplyGlobalTemplateToWebs(List`1 lstwebinfoToUpgrade, List`1& lstwebinfoExceptions)
[ScriptEditor] [SPWebTemplateSequence] [DEBUG] [12/8/2011 7:04:24 PM]: Template MPS#0: Exception thrown while applying the global template to the web with URL "(unknown)" (Id: 'be229958-2680-4d85-ba72-79f036ab075a') from site with URL "(unknown)" (Id: '3e800bc3-296f-47f0-a04d-b1e4ae385cb8'). Adding web to the exceptions list. Exception: System.IO.FileNotFoundException: The site with the id 3e800bc3-296f-47f0-a04d-b1e4ae385cb8 could not be found.
   at Microsoft.SharePoint.SPSite..ctor(Guid id, SPFarm farm, SPUrlZone zone, SPUserToken userToken)
   at Microsoft.SharePoint.SPSite..ctor(Guid id)
   at Microsoft.SharePoint.Upgrade.SPWebTemplateSequence.ApplyGlobalTemplateToWebs(List`1 lstwebinfoToUpgrade, List`1& lstwebinfoExceptions)
[ScriptEditor] [SPWebTemplateSequence] [DEBUG] [12/8/2011 7:04:24 PM]: Template MPS#0: Exception thrown while applying the global template to the web with URL "(unknown)" (Id: '79ae9a08-845b-4502-affe-a836b7783ae8') from site with URL "(unknown)" (Id: '3e800bc3-296f-47f0-a04d-b1e4ae385cb8'). Adding web to the exceptions list. Exception: System.IO.FileNotFoundException: The site with the id 3e800bc3-296f-47f0-a04d-b1e4ae385cb8 could not be found.
   at Microsoft.SharePoint.SPSite..ctor(Guid id, SPFarm farm, SPUrlZone zone, SPUserToken userToken)
   at Microsoft.SharePoint.SPSite..ctor(Guid id)
   at Microsoft.SharePoint.Upgrade.SPWebTemplateSequence.ApplyGlobalTemplateToWebs(List`1 lstwebinfoToUpgrade, List`1& lstwebinfoExceptions)
[ScriptEditor] [SPWebTemplateSequence] [DEBUG] [12/8/2011 7:04:24 PM]: Template MPS#0: Exception thrown while applying the global template to the web with URL "(unknown)" (Id: '27a97c8e-3652-4fe2-9fe2-ca8d47eca28d') from site with URL "(unknown)" (Id: '3e800bc3-296f-47f0-a04d-b1e4ae385cb8'). Adding web to the exceptions list. Exception: System.IO.FileNotFoundException: The site with the id 3e800bc3-296f-47f0-a04d-b1e4ae385cb8 could not be found.
   at Microsoft.SharePoint.SPSite..ctor(Guid id, SPFarm farm, SPUrlZone zone, SPUserToken userToken)
   at Microsoft.SharePoint.SPSite..ctor(Guid id)
   at Microsoft.SharePoint.Upgrade.SPWebTemplateSequence.ApplyGlobalTemplateToWebs(List`1 lstwebinfoToUpgrade, List`1& lstwebinfoExceptions)
[ScriptEditor] [SPWebTemplateSequence] [DEBUG] [12/8/2011 7:04:24 PM]: Template MPS#0: Exception thrown while applying the global template to the web with URL "(unknown)" (Id: '4d755906-d3ca-4c23-b505-d7f0f5ef0a2c') from site with URL "(unknown)" (Id: '3e800bc3-296f-47f0-a04d-b1e4ae385cb8'). Adding web to the exceptions list. Exception: System.IO.FileNotFoundException: The site with the id 3e800bc3-296f-47f0-a04d-b1e4ae385cb8 could not be found.
   at Microsoft.SharePoint.SPSite..ctor(Guid id, SPFarm farm, SPUrlZone zone, SPUserToken userToken)
   at Microsoft.SharePoint.SPSite..ctor(Guid id)
   at Microsoft.SharePoint.Upgrade.SPWebTemplateSequence.ApplyGlobalTemplateToWebs(List`1 lstwebinfoToUpgrade, List`1& lstwebinfoExceptions)
[ScriptEditor] [SPWebTemplateSequence] [DEBUG] [12/8/2011 7:04:24 PM]: Template MPS#0: Exception thrown while applying the global template to the web with URL "(unknown)" (Id: '8cc79a95-c567-4b8d-902e-ed944d64d84d') from site with URL "(unknown)" (Id: '3e800bc3-296f-47f0-a04d-b1e4ae385cb8'). Adding web to the exceptions list. Exception: System.IO.FileNotFoundException: The site with the id 3e800bc3-296f-47f0-a04d-b1e4ae385cb8 could not be found.
   at Microsoft.SharePoint.SPSite..ctor(Guid id, SPFarm farm, SPUrlZone zone, SPUserToken userToken)
   at Microsoft.SharePoint.SPSite..ctor(Guid id)
   at Microsoft.SharePoint.Upgrade.SPWebTemplateSequence.ApplyGlobalTemplateToWebs(List`1 lstwebinfoToUpgrade, List`1& lstwebinfoExceptions)
[ScriptEditor] [SPWebTemplateSequence] [DEBUG] [12/8/2011 7:04:24 PM]: Template MPS#0: Exception thrown while applying the global template to the web with URL "(unknown)" (Id: 'ec8f2991-c91a-41af-84be-fef8597035a2') from site with URL "(unknown)" (Id: '3e800bc3-296f-47f0-a04d-b1e4ae385cb8'). Adding web to the exceptions list. Exception: System.IO.FileNotFoundException: The site with the id 3e800bc3-296f-47f0-a04d-b1e4ae385cb8 could not be found.
   at Microsoft.SharePoint.SPSite..ctor(Guid id, SPFarm farm, SPUrlZone zone, SPUserToken userToken)
   at Microsoft.SharePoint.SPSite..ctor(Guid id)
   at Microsoft.SharePoint.Upgrade.SPWebTemplateSequence.ApplyGlobalTemplateToWebs(List`1 lstwebinfoToUpgrade, List`1& lstwebinfoExceptions)

Solution in my case:

There was an incorrect managed path in the web applications configured. The managed path was available, but set to “Wildcard inclusion” in the new farm (2010) instead of “Explicit inclusion” as in the old farm (2007).

I did remove the managed path and added it again with the correct setting. After that I had to re-attach the content database. The error was gone.

Exclude Asset Library from search results by modifying search scopes

It’s possible to exclude SharePoint Lists from search results by excluding their types in the search scope definition.

Therefore you need to define an search scope rule based on a “property”. You have to use “contentclass” and a value.

There are much lists of the possible values out in the web.

Here is mine 🙂

Value Description
STS_Web Site
STS_List Custom List
STS_ListItem Custom List item
STS_List_DocumentLibrary Document Library
STS_ListItem_DocumentLibrary Document Libary item
STS_List_Links Link List
STS_ListItem_Links Link List item
STS_List_Events Event List
STS_ListItem_Events Event List item
STS_List_Tasks Task List
STS_ListItem_Tasks Task List item
STS_List_Contacts Contact List
STS_ListItem_Contacts Contact List item
STS_List_Announcements Announcements List
STS_ListItem_Announcements Announcements List item
STS_List_DiscussionBoard Discussion Board
STS_ListItem_DiscussionBoard Discussion Board item
STS_List_GanttTasks Gantt Task List
STS_ListItem_GanttTasks Gantt Task item
STS_List_IssueTracking Issue Tracking list
STS_ListItem_IssueTracking Issue Tracking item
STS_List_Survey Survey
STS_ListItem_Survey Survey item
STS_List_PictureLibrary Picture Library
STS_ListItem_PictureLibrary Picture Library Item
STS_List_WebPageLibrary Web Page Library
STS_ListItem_WebPageLibrary Web Page Library Item
STS_List_XMLForm (InfoPath) Form Library
STS_ListItem_XMLForm (InfoPath) Form Library item
STS_List_850 Page Library
STS_ListItem_850 Page Library item
urn:content-class:SPSSearchQuery Search Query
urn:content-class:SPSListing:News News Listing
urn:content-class:SPSPeople People
urn:content-classes:SPSCategory Category
urn:content-classes:SPSListing Listing
urn:content-classes:SPSPersonListing Person Listing
urn:content-classes:SPSTextListing Text Listing
urn:content-classes:SPSSiteListing Site Listing
urn:content-classes:SPSSiteRegistry Site Registry Listing

 

You can generally exclude list items from search by using the value “STS_ListItem_PictureLibrary” for the property “contentclass”.

But how to exclude items or lists of type “Asset Library” which is also a standard list template like “Document Library”, “Picture Library”, “Calendar List”, … and “Page Library” which has as code (850) as name. (Marked red in the list above.)

I checked the 14 hive and figured out the 850 is the list template ID of “Page Library”. And the list template ID of “Asset Library” is 851.

So I used the following query in the search box: “(scope:"All Websites") (contentclass:STS_List_851)

I created a new search scope exclude rule on the site collection using “STS_List_851” in it worked! Now there are no more Asset Libary links in the search result. If you you “STS_ListItem_851” you can exclude Asset Library Litems.

(No screenshots today, sorry!)

PowerShell Script for Recreating the Server Cache (related to error in Windows Event Log, Event ID 6482: Application Server Administration job failed for service instance Microsoft.Office.Server.Search.Administration.SearchServiceInstance)

Today I’ve had the error:

Application Server Administration job failed for service instance Microsoft.Office.Server.Search.Administration.SearchServiceInstance (150CA1DD-02E3-47C0-AA55-005A2927751F).

Reason: An update conflict has occurred, and you must re-try this action. The object SearchDataAccessServiceInstance was updated by DOMAINspfarm, in the OWSTIMER (5040) process, on machine sps2010. 
View the tracing log for more information about the conflict.

Technical Support Details:
Microsoft.SharePoint.Administration.SPUpdatedConcurrencyException: An update conflict has occurred, and you must re-try this action.
The object SearchDataAccessServiceInstance was updated by domainuser, in the OWSTIMER (5040) process, on machine (server name). 
View the tracing log for more information about the conflict.
   at Microsoft.Office.Server.Search.Administration.SearchServiceInstance.Synchronize()
   at Microsoft.Office.Server.Administration.ApplicationServerJob.ProvisionLocalSharedServiceInstances(Boolean isAdministrationServiceJob)

 

There is a nice article on Jeff DeVerter’s blog:

Jeff references to this articles:

I had to clean up lots of servers. Because of that I’ve created a little PowerShell script.

The script will automatically process all steps descripted by the KB article, Chaitu Madala and Jeff.

You can execute the script on every server.

If your receive a yellow message at the end of the process that the resulting “cache.ini” file is diffrent from the original one. I think the cache.ini file contains a timestamp and it is OK if the new timestamp value is greater than the original one… But you use the script at your own rist – as always.

 

SCRIPT:

# Script created by Ingo Karstein (https://blog.kenaro.com)
Write-Host "Script created by Ingo Karstein (https://blog.kenaro.com)" -ForegroundColor DarkGreen

$cacheFolderRoot = Join-Path ${env:ProgramData} "MicrosoftSharePointConfig"
$cacheFileCopy = Join-Path ${env:temp} "cacheFileTmp.ini.ik"

Write-Host "" -ForegroundColor DarkBlue
Write-Host "Starting" -ForegroundColor DarkBlue

if( Test-Path $cacheFileCopy -PathType Leaf) {
    write-host "Cache File copy lopcation does already exist. Please remove it: $($cacheFileCopy)" -ForegroundColor Red
    return
}

Write-Host "Looking for cache folder" -ForegroundColor DarkBlue
$cacheFolder =  @(GEt-ChildItem -Path $cacheFolderRoot | ? {Test-Path $_.FullName -PathType Container} | ? {Test-Path -Path (Join-Path $_.FullName "cache.ini") -PathType Leaf})

if( $cacheFolder -ne $null -and $cacheFolder.Count -eq 1) {
    $cacheFolder0 = $cacheFolder[0].FullName
    Write-Host "Cache folder found: $($cacheFolder0)" -ForegroundColor DarkBlue
    $cacheFile = join-path $cacheFolder0 "cache.ini"
    Write-Host "Cache ini file: $($cacheFile)" -ForegroundColor DarkBlue

    Write-Host "Stop SharePoint timer service" -ForegroundColor DarkBlue
    stop-service sptimerv4

    Write-Host "Copy cache.ini to it's temp location ($($cacheFileCopy))" -ForegroundColor DarkBlue
    copy-item -path $cacheFile -Destination $cacheFileCopy -force

    Write-Host "Set the content of cache.ini to ""1""" -ForegroundColor DarkBlue
    "1" | set-content $cacheFile -encoding ascii -force

    Write-Host "Remove all .XML files from the cache folder" -ForegroundColor DarkBlue
    get-childitem $cacheFolder0 -filter "*.xml" | remove-item -force -confirm:$false

    Write-Host "Start SharePoint timer service" -ForegroundColor DarkBlue
    start-service sptimerv4

    $xmlFound = -1
    $xmlFoundLast = -1
    $eqCount = 0

    Write-Host "Now the cache will be recreated... Waiting... This will take a minute or so..." -ForegroundColor DarkBlue
    write-host "(every second a dot will appear on the end of the next line)" -ForegroundColor gray
    do {
        write-host "." -nonewline -ForegroundColor Magenta
        start-sleep -second 1
        $xmlFoundLast = $xmlFound
        $xmlFound = (@(get-childitem $cacheFolder0 -filter "*.xml")).Count
        if( $xmlFound -eq $xmlFoundLast ) {
            $eqCount++
        } else {
            $eqCount = 0
        }
    } while ($eqCount -lt 30)
    
    Write-Host ""
    Write-Host "Done" -ForegroundColor DarkBlue

    $a = get-content $cacheFileCopy
    $b = get-content $cacheFile

    if( $a -ne $b ) {
        if( [int]$a -gt [int]$b ) {
            write-host "An error occured. the content of the cache file is not identically to it's value before processing." -ForegroundColor Red
            write-host "Old: $($a)"
            write-host "New: $($b)"    
        } else {
            write-host "MAYBE an error occured. the content of the cache file is not identically to it's value before processing." -ForegroundColor DarkYellow
            write-host "Old: $($a)"
            write-host "New: $($b)"    
        }
    } else {
        write-host "Processing finished successfully! You need to execute the  script on every server!!" -foregroundcolor darkgreen
        remove-item $cacheFileCopy -Force -confirm:$false
    }
} else {
    write-host "Could not find the cache folder or found too much cache folders!" -foregroundcolor red
}

Strange Error on Web Frontend Server of MOSS 2007 farm: stsadm operation “enumallwebs” with “includewebparts” options results in lots of missing WebParts

During a migration project from MOSS 2007 to SharePoint 2010 we got a strange error that took some hours to resolve.

For an automated migration tasks I tried to create a PowerShell script to enumerate all WebParts on all ASPX pages using SPLimitedWebPartManager on a WFE of the MOSS 2007 farm. But I only got “ErrorWebPart” for every WebPart on the Web Application!

Then I used “stsadm” to enumerate all WebParts:

stsadm –o enumallwebs –databasename sharepoint_content_local_sharepoint_local –includewebparts > allwebparts.txt

This is the result:

<Databases>
  <Database SiteCount="2" Name="sharepoint_content_local_sharepoint_local" DataSource="server">
    <Site Id="12345678-716d-44a3-a973-fffffffffff" OwnerLogin="domainspadmin" InSiteMap="True">
      <Webs Count="5">
        <Web Id="12345678-17d9-4870-8d94-fffffffffff" Url="/sites/test1" LanguageId="1031" TemplateName="STS#0" TemplateId="1">
          <WebParts>
            <WebPart Id="00f5bad9-f117-4eca-8d77-194bb598d7c6" Count="1" Status="Missing" />
            <WebPart Id="e398c8f4-1750-b857-cca9-2542cadaee8f" Count="1" Status="Missing" />
            <WebPart Id="d23f666e-372e-8f7d-e9f4-341c7fab5653" Count="1" Status="Missing" />
            <WebPart Id="9f7a9f30-76a0-2d43-0d84-402ba6c3c125" Count="1" Status="Missing" />
            <WebPart Id="ce9aa113-48cf-ddee-0c03-597445e5b7ab" Count="1" Status="Missing" />
            <WebPart Id="e60f6c95-e86c-4717-2c0d-6d8563c9caf7" Count="1" Status="Missing" />
            <WebPart Id="293e8d0e-486f-e21e-40e3-75bfb77202de" Count="103" Status="Missing" />
            <WebPart Id="6bbb6e7d-fe0d-5d79-6c79-76a90de47e1c" Count="1" Status="Missing" />
            <WebPart Id="9f030319-fa14-b625-4892-89f6f9f9d58b" Count="1" Status="Missing" />
            <WebPart Id="b9a7f972-708a-cd77-4ffd-a235dfed5c38" Count="1" Status="Missing" />
            <WebPart Id="2242cce6-491a-657a-c8ee-b10a2a993eda" Count="182" Status="Missing" />
            <WebPart Id="db128878-9a93-4768-2256-cc2c390ffb57" Count="1" Status="Missing" />
          </WebParts>
        </Web>
        <Web Id="12345678-3bda-4109-aacd-fffffffffff" Url="/sites/test1/subweb1" LanguageId="1031" TemplateName="STS#1" TemplateId="1">
          <WebParts>
            <WebPart Id="ce9aa113-48cf-ddee-0c03-597445e5b7ab" Count="1" Status="Missing" />
            <WebPart Id="293e8d0e-486f-e21e-40e3-75bfb77202de" Count="9" Status="Missing" />
            <WebPart Id="2242cce6-491a-657a-c8ee-b10a2a993eda" Count="7" Status="Missing" />
          </WebParts>
        </Web>
        <Web Id="12345678-b479-4157-91e5-fffffffffff" Url="/sites/test1/subweb2" LanguageId="1031" TemplateName="STS#1" TemplateId="1">
          <WebParts>
            <WebPart Id="ce9aa113-48cf-ddee-0c03-597445e5b7ab" Count="1" Status="Missing" />
            <WebPart Id="293e8d0e-486f-e21e-40e3-75bfb77202de" Count="6" Status="Missing" />
            <WebPart Id="2242cce6-491a-657a-c8ee-b10a2a993eda" Count="5" Status="Missing" />
          </WebParts>
        </Web>
        <Web Id="12345678-25f3-450f-b44d-fffffffffff" Url="/sites/test1/subweb3" LanguageId="1031" TemplateName="STS#0" TemplateId="1">
          <WebParts>
            <WebPart Id="ce9aa113-48cf-ddee-0c03-597445e5b7ab" Count="1" Status="Missing" />
            <WebPart Id="293e8d0e-486f-e21e-40e3-75bfb77202de" Count="21" Status="Missing" />
            <WebPart Id="2242cce6-491a-657a-c8ee-b10a2a993eda" Count="22" Status="Missing" />
          </WebParts>
        </Web>
        <Web Id="12345678-b341-4370-b0c6-fffffffffff" Url="/sites/test1/subweb4" LanguageId="1031" TemplateName="STS#0" TemplateId="1">
          <WebParts>
            <WebPart Id="ce9aa113-48cf-ddee-0c03-597445e5b7ab" Count="1" Status="Missing" />
            <WebPart Id="e60f6c95-e86c-4717-2c0d-6d8563c9caf7" Count="1" Status="Missing" />
            <WebPart Id="293e8d0e-486f-e21e-40e3-75bfb77202de" Count="23" Status="Missing" />
            <WebPart Id="2242cce6-491a-657a-c8ee-b10a2a993eda" Count="27" Status="Missing" />
          </WebParts>
        </Web>
      </Webs>
    </Site>
    <Site Id="12345678-730c-46fd-a114-fffffffffff" OwnerLogin="domainspadmin" InSiteMap="True">
      <Webs Count="2">
        <Web Id="12345678-7cd6-447d-8107-fffffffffff" Url="/sites/test2" LanguageId="1031" TemplateName="STS#0" TemplateId="1">
          <WebParts>
            <WebPart Id="d55b3b6b-6281-707b-73d0-0c49581475ad" Count="1" Status="Missing" />
            <WebPart Id="aadc2962-fc63-03e2-f119-13e7096bab20" Count="1" Status="Missing" />
            <WebPart Id="2f1510c7-75d5-921f-b120-2ce98fe3afe3" Count="1" Status="Missing" />
            <WebPart Id="f5c3ff60-e752-3a90-84f8-3677f8384e2d" Count="2" Status="Missing" />
            <WebPart Id="f2c50a02-9894-4ace-bb3f-4146a24cd940" Count="2" Status="Missing" />
            <WebPart Id="ce9aa113-48cf-ddee-0c03-597445e5b7ab" Count="2" Status="Missing" />
            <WebPart Id="e60f6c95-e86c-4717-2c0d-6d8563c9caf7" Count="2" Status="Missing" />
            <WebPart Id="293e8d0e-486f-e21e-40e3-75bfb77202de" Count="83" Status="Missing" />
            <WebPart Id="9f030319-fa14-b625-4892-89f6f9f9d58b" Count="1" Status="Missing" />
            <WebPart Id="c9b34b5d-bf06-dc91-d23e-94ecad31cd0a" Count="2" Status="Missing" />
            <WebPart Id="2242cce6-491a-657a-c8ee-b10a2a993eda" Count="83" Status="Missing" />
            <WebPart Id="74bd016c-baa0-14a8-d5d8-b75dc7e6f429" Count="1" Status="Missing" />
            <WebPart Id="94e9c166-264a-f84b-2377-bccefb8b3771" Count="1" Status="Missing" />
            <WebPart Id="fb35a198-aea0-3c26-e40c-df473fe9b07b" Count="2" Status="Missing" />
            <WebPart Id="669602d9-e116-ccb8-eea3-e37ad589b14b" Count="1" Status="Missing" />
            <WebPart Id="f5897322-ddd4-c990-d012-f9d4fe2180ad" Count="2" Status="Missing" />
          </WebParts>
        </Web>
        <Web Id="12345678-80e5-425d-b0d9-fffffffffff" Url="/sites/test4" LanguageId="1031" TemplateName="STS#0" TemplateId="1">
          <WebParts>
            <WebPart Id="ce9aa113-48cf-ddee-0c03-597445e5b7ab" Count="1" Status="Missing" />
            <WebPart Id="e60f6c95-e86c-4717-2c0d-6d8563c9caf7" Count="1" Status="Missing" />
            <WebPart Id="293e8d0e-486f-e21e-40e3-75bfb77202de" Count="81" Status="Missing" />
            <WebPart Id="2242cce6-491a-657a-c8ee-b10a2a993eda" Count="105" Status="Missing" />
          </WebParts>
        </Web>
      </Webs>
    </Site>
  </Database>
</Databases>

(This file is modified: I’ve changed Web and Site IDs and I’ve removed lots of webs and sites.)

EVERY WEBPART IS MISSING!! Also all default MOSS 2007 WebParts with default SharePoint DLLs!

BUT… On the second Web Frontend Server all WebParts are Status=”Installed” !!! Strange…

In the events viewer we found:

clip_image002

image

It’s a SharePoint Feature DLL that is missing!

This error is not present on the second WFE!

So we installed the missing DLL in the GAC.

And… now it works! – All WebParts have status “Installed” in the stsadm output!

Summary

The feature deployment on the WFE was not successfull. There must be an error but MOSS 2007 doesn’t tell us about it. All solutions seems to be deployed in the Solution Management of the farm…

Deploying “Fantastic Fourty“ templates of MOSS 2007 on SharePoint 2010

There are the “Fantastic Fourty” templates you all now… They are create for MOSS 2007 and there are no update available for SharePoint 2010… Because of a migration of MOSS 2007 to SharePoint 2010 I need to deploy some of the site definitions to SharePoint 2010 to get the “old” sites working…

Do you know you can publish the Fantastic-40 on SharePoint 2010? – Here is a nice article about that: http://marijnsomers.blogspot.com/2010/06/fantastic-40-templates-on-sharepoint.html

On this page you’ll find updates solution packages: http://techsolutions.net/Blog/tabid/65/EntryId/17/Fab-40-Templates-for-MOSS-2010.aspx

 

BUT…

After deployment of the base solution “ApplicationTemplateCore.wsp” this is what I liked to do:

1. Create a Site Collection

image

2. Enter some data and choose the “Custom” category for the site template. Click “Select template later”…

SNAGHTMLc2b02f

3. Now create the site and open them. You get:

image

4. Now open the “Site Settings” from the “Site Actions” menu.

5. Click “Site Collection Features”.

6. Try to activate feature “Fields and Content Types for the Windows SharePoint Services Application Templates”

image

7. You get:

image

 

But as I tried to deploy and activate them I got this error:

  

Server Error in '/' Application.
--------------------------------------------------------------------------------

The field with Id {46b00cd2-bc51-45d8-87e1-68f1be35275f} defined in feature {75a0fea7-cd50-401e-af0e-782f3662a299} was found in the current site collection or in a subsite. 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: Microsoft.SharePoint.SPException: The field with Id {46b00cd2-bc51-45d8-87e1-68f1be35275f} defined in feature {75a0fea7-cd50-401e-af0e-782f3662a299} was found in the current site collection or in a subsite.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. 

 

Stack Trace:

[SPException: The field with Id {46b00cd2-bc51-45d8-87e1-68f1be35275f} defined in feature {75a0fea7-cd50-401e-af0e-782f3662a299} was found in the current site collection or in a subsite.]

   Microsoft.SharePoint.Utilities.SPUtility.ThrowSPExceptionWithTraceTag(UInt32 tagId, ULSCat traceCategory, String resourceId, Object[] resourceArgs) +27772295   

Microsoft.SharePoint.Administration.SPElementDefinitionCollection.ProvisionFieldsAndContentTypes(SPFeaturePropertyCollection props, SPSite site, SPWeb web, Boolean fForce) +23652209   

Microsoft.SharePoint.Administration.SPElementDefinitionCollection.ProvisionElements(SPFeaturePropertyCollection props, SPWebApplication webapp, SPSite site, SPWeb web, Boolean fForce) +138   

Microsoft.SharePoint.SPFeature.Activate(SPSite siteParent, SPWeb webParent, SPFeaturePropertyCollection props, Boolean fForce) +25437423   

Microsoft.SharePoint.SPFeatureCollection.AddInternal(SPFeatureDefinition featdef, Version version, SPFeaturePropertyCollection properties, Boolean force, Boolean fMarkOnly) +27496895   

Microsoft.SharePoint.SPFeatureCollection.AddInternalWithName(Guid featureId, String featureName, Version version, SPFeaturePropertyCollection properties, Boolean force, Boolean fMarkOnly, SPFeatureDefinitionScope featdefScope) +150   

Microsoft.SharePoint.SPFeatureCollection.Add(Guid featureId, Boolean force, SPFeatureDefinitionScope featdefScope) +83   

Microsoft.SharePoint.WebControls.FeatureActivator.ActivateFeature(Guid featid, SPFeatureDefinitionScope featdefScope) +699   

Microsoft.SharePoint.WebControls.FeatureActivatorItem.BtnActivateFeature_Click(Object objSender, EventArgs evtargs) +140   

System.Web.UI.WebControls.Button.OnClick(EventArgs e) +115    System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +140   

System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +29    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2981

 

Okay… This is the solution that I’ve developed some minutes ago.

1. You need to decompress the “ApplicationTemplateCore.WSP” file. – It’s nothing else than a CAB file renamed to WSP. – Use 7zip to decompress it.

2. Open the file <fantastic40-folder>ApplicationTemplateCoreTSATypesFields.xml. Search for 46b00cd2-bc51-45d8-87e1-68f1be35275f and remove one of the double entries of this field definition:

SNAGHTML5a2ab1a

image

(Remove the code in the red frame.)

3. By the way: This is not the only bug in the WSP file. But for now we go ahead… We need to recreate the WSP file.

This is not easy.

a) First download “DDFGenerator.exe” from http://ddfgenerator.codeplex.com/

b) Open a command line prompt.

c) Type the path to “DDFGenerator.exe” and specify the path of the WSP content as parameter.

image

d) In the WSP content folder you’ll find a file named “solution.ddf”. Edit this file in Notepad. Insert “.Set CabinetNameTemplate=ApplicationTemplateCore.WSP” as 5th line. – Save and close the file.

image

e) Go into the folder and execute “MakeCab.exe /F solution.ddf”

SNAGHTMLda5e2a

Now you have a new WSP file in a sub folder of the WSP content folder.

image

4. Now run a solution upgrade.

5. Try to activate the feature again. You get another error:

image

The field with Id {26118c12-ea11-48ae-950b-a7219a9738f8} defined in feature {75a0fea7-cd50-401e-af0e-782f3662a299} was found in the current site collection or in a subsite. 

6. If your search for GUID “26118c12-ea11-48ae-950b-a7219a9738f8” you’ll find another field that is deployed twice:

<Field ID="{26118C12-EA11-48ae-950B-A7219A9738F8}" Name="TextFileName" DisplayName="$Resources:core,Name;" Type="Text" Group="_Hidden" Sealed="TRUE" AllowDeletion="FALSE"></Field>

…in file <fantastic40-folder>ApplicationTemplateCoreTSATypesFields.xml

Here you need to delete one of the entries…

7. The next try also results in an error:

image

The field with Id {ebb85cf8-047c-4ba7-9fd6-01bfa5ef126d} defined in feature {75a0fea7-cd50-401e-af0e-782f3662a299} was found in the current site collection or in a subsite.

8. Search for GUID “ebb85cf8-047c-4ba7-9fd6-01bfa5ef126d”. – Here it’s more complexe to resolve this issue. Because there are to diffrent fields with the same ID!

image

(It’s file <fantastic40-folder>ApplicationTemplateCoreTSATypesFields.xml again!)

You need to create a new ID for one of the field.

I’ve choosen “93B5756C-727F-4C4B-A081-E8654A234739” as new ID for field “AssetPurchasePrice”. You can use this GUID too!

Now you need to change every reference to field “AssetPurchasePrice” in all files of the project. Here is a list of files:

  • <fantastic40-folder>ApplicationTemplateCoreTSATypesFields.xml
  • <fantastic40-folder>ApplicationTemplateCoreTSATypesCTypes.xml
  • <fantastic40-folder>ApplicationTemplateCoreLendingLibraryListAssetsschema.xml
  • <fantastic40-folder>ApplicationTemplateCoreInventoryTrackingInventoryListInventoryschema.xml
  • <fantastic40-folder>ApplicationTemplateCoreAssetTrackingProposalsListProposalsschema.xml
  • <fantastic40-folder>ApplicationTemplateCoreAssetTrackingAssetsListAssetsschema.xml

Be sure to replace the ID of all references of “AssetPurchasePrice” with the new ID! Don’t touch the references of the other field “AssetDateRetired” with the same ID. Do not use Search and Replace to replace the GUID.

A sample for file <fantastic40-folder>ApplicationTemplateCoreAssetTrackingAssetsListAssetsschema.xml after replacing the ID of “AssetPurchasePrice”:

image

(In the red box I’ve replaced the ID. In the green oval I’ve left the ID untouched!)

BTW: The GUID of “AssetDateRetired” is “EBB85CF8-047C-4ba7-9FD6-01BFA5EF126D”: There are lower case letters and upper case letters in the GUID. I think they are edited by hand by someone and that’s the reason of the error…

9. Save your work and repack the solution as described above and deploy the package to SharePoint.

10. Now I’m able to activate the feature “Fields and Content Types for the Windows SharePoint Services Application Templates”:

image

12. That’s it so far.

13. Now I’d like to use a Fantastic-40 template. In my case “Helpdesk”. I deployed the “Helpdesk.WSP” of the Fantastic-40 bundle to SharePoint 2010. – Without any error.

14. Click the homepage of your site and you’ll reach the “Template Picker” application page if you did not select a template for the site before like me.

image

15. Now I have a working “Helpdesk” site – as far as I can see.

image

PowerShell Tool to Enumerate the Content Type Usage in SharePoint 2010

A customer of mine has the problem that he wants to remove a Web Content Type but SharePoint says the content type is still in use.

Therefore I created a tool for enumerating all web and list content types of all sites.

The following script scans the SharePoint farm and creates a Windows form with a Treeview like this:

image

(Web) = Web Content Types

(List) = List Content Types

The tool show the content type inheritence:

image

Here you see the List Content Type “Image” that based on the Web Content Type “Image” that based on the Web Content Type “Rich Media Asset” that based on Web Content Type “Document” that is inherited from the “System” Content Type.

It’s possible to open the content type management site by clicking “_open management site” or open the related list or web by clicking “_open list” or “_open web”.

This is the script:

#region Init
    Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
    [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") | Out-Null
    [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")  | Out-Null
    cls
#endregion

#region Form
    $form = New-Object System.Windows.Forms.Form

    $button = New-Object System.Windows.Forms.Button
    $treeview = New-Object System.Windows.Forms.TreeView

    $form.SuspendLayout()

    $button.DialogResult = [System.Windows.Forms.DialogResult]::Cancel
    $button.Dock = [System.Windows.Forms.DockStyle]::Bottom
    $button.Location = (new-object System.Drawing.Point(0, 250))
    $button.Name = "button1"
    $button.Size = (new-object System.Drawing.Size(292, 23))
    $button.TabIndex = 0
    $button.Text = "Close"
    $button.UseVisualStyleBackColor = $true

    $treeview.Dock = [System.Windows.Forms.DockStyle]::Fill
    $treeview.Location = (new-object System.Drawing.Point(0, 0))
    $treeview.Name = "treeView1"
    $treeview.Size = (new-object System.Drawing.Size(292, 250))
    $treeview.TabIndex = 1

    $form.AutoScaleDimensions = new-object System.Drawing.SizeF(6.0, 13.0)
    $form.AutoScaleMode = [System.Windows.Forms.AutoScaleMode]::Font
    $form.ClientSize = (new-object System.Drawing.Size(292, 273))
    $form.Controls.Add($button)
    $form.Controls.Add($treeview)
    $form.Name = "Content Type Usage "
    $form.Text = "Content Type Usage / https://blog.kenaro.com"
    $form.ResumeLayout($false)
#endregion

$list = @{}

$treeview.add_NodeMouseDoubleClick({
    param($sender, $eventArgs)
    if($eventArgs.Node.Tag -ne $null ) {
        [System.Diagnostics.Process]::Start($eventArgs.Node.Tag)
    }
});

function analyseWeb {
    param([Microsoft.SharePoint.SPWeb]$web) 
    
    $web.ContentTypes | % {
        $ct = $_
        $global:list += @{"$($ct.Id)"=$ct}
    }
    
    $web.lists | % {
        $_.ContentTypes | % {
            $ct = $_
            $global:list += @{"$($ct.Id)"=$ct}
        }
    }
    
    $web.Webs | % {
        analyseWeb -web $_
    }
}

function reorder {
    param([Microsoft.SharePoint.SPContentType]$p = $null, [int]$intend, [System.Windows.Forms.TreeNode]$parentNode)
    
    if( $p -eq $null ) {
        $ct = $list["0x"]

        $tn = New-Object System.Windows.Forms.TreeNode("System")
        $tn.ToolTipText = "0x"
        $parentNode.Nodes.Add($tn) | Out-Null
        
        reorder -p $ct -intend 0 -parentNode $tn
    } else {
        ($list.Values | ? {$_.Id.IsChildOf($p.Id) -and $_ -ne $p} | sort @{Expression={$_.Id.ToString().Length}}, $_.Id.ToString() ) | % {
            $ct = $_
            $type=""
            $url=""
            $tn = $null

            if( $ct.ParentList -ne $null ) {
                $type="(List) $($ct.Name) / List: $($ct.ParentList.Title) / Id: $($ct.Id.ToString())"            
                $url = $ct.parentweb.url + "/_layouts/ManageContentType.aspx?ctype=" + $ct.Id.ToString()+"&List="+$ct.ParentList.Id.ToString()
                
                #http://<domain>/sites/<web>/_layouts/ManageContentType.aspx?List=%7B111963EB%2DF504%2D49EC%2DA21B%2D814319718684%7D&ctype=0x010100644EE9F5F657474B92A2716207BB5DE2
                
                $tn = New-Object System.Windows.Forms.TreeNode($type)
                $tn1 = New-Object System.Windows.Forms.TreeNode("_open management site")
                $tn1.Tag = $url
                $tn.Nodes.Add($tn1) | Out-Null
                
                $tn2 = New-Object System.Windows.Forms.TreeNode("_open list")
                $tn2.Tag = $ct.ParentWeb.Site.MakeFullUrl($ct.ParentList.DefaultViewUrl)
                $tn.Nodes.Add($tn2) | Out-Null
            }else {
                $type="(Web) $($ct.Name) / Id: $($ct.Id.ToString())"
                $url = $ct.parentweb.url + "/_layouts/ManageContentType.aspx?ctype=" + $ct.Id.ToString()
            
                #http://<domain>/sites/<web>/_layouts/ManageContentType.aspx?ctype=0x0100CF8FCF53E9FA451CB145093F830B1762
                $tn = New-Object System.Windows.Forms.TreeNode($type)
                $tn1 = New-Object System.Windows.Forms.TreeNode("_open management site")
                $tn1.Tag = $url

                $tn.Nodes.Add($tn1) | Out-Null
                $tn2 = New-Object System.Windows.Forms.TreeNode("_open web")
                $tn2.Tag = $ct.ParentWeb.Url
                $tn.Nodes.Add($tn2) | Out-Null
            }

            $parentNode.Nodes.Add($tn) | Out-Null
        
            reorder -p $ct -intend ($intend+1) -parentNode $tn
        }
    }
}

if($fileName -ne $null ) { 
    Remove-Item -Path $fileName -Confirm:$false -ErrorAction SilentlyContinue
}

#you can filter the processed site collections in the following line
Get-SPSite -Limit all <#| select -first 1 -Skip 10#> | % {
    $site = $_
    $tn = New-Object System.Windows.Forms.TreeNode("Site: $($site.Url)")
    $treeview.Nodes.Add($tn)
    
    $rootWeb = $site.RootWeb
    
    analyseWeb -web $rootWeb
    
    reorder -parentNode $tn
    
    $rootWeb.Dispose()
    $site.Dispose()
}

$form.ShowDialog() | out-null