查询Feature的名称及ID

List<Guid> featIDs = new List<Guid>();

            var dd = from i in SPFarm.Local.FeatureDefinitions

                     where i != null && i.RootDirectory.Contains("NanmuThemes")

                     select i;

            //NanmuThemes

            //290836a1-823f-4b34-9268-6727546e5dab

            //stsadm.exe -o uninstallfeature -id <feature_giud> -force.

            foreach (SPFeatureDefinition featdef in dd)

            {

                try

                {

                    Console.WriteLine(featdef.RootDirectory + "-------" + featdef.Id.ToString() + "-------" + featdef.GetTitle(System.Threading.Thread.CurrentThread.CurrentCulture));

                }

                catch

                {

 

                    //This code will be executed if the feature does not have the manifest file.

                    Console.WriteLine("################################################");

                    Console.WriteLine("Error Ocurrred! Attempting to get feature ID of the feature without manifest file...:");

                    Console.WriteLine(featdef.Id.ToString());

                }

                finally

                {

                    Console.WriteLine();

                    Console.WriteLine("Press enter to view next feature");

                    Console.ReadLine();

                }

            }

如果出问题,可以使用

C:\>stsadm.exe -o uninstallfeature -id <id> –force 卸载

 

 

List<Guid> featIDs = new List<Guid>();

            var dd = from i in SPFarm.Local.FeatureDefinitions

                     where i != null && i.RootDirectory.Contains("NanmuThemes")

                     select i;

            //NanmuThemes

            //290836a1-823f-4b34-9268-6727546e5dab

            //stsadm.exe -o uninstallfeature -id <feature_giud> -force.

            foreach (SPFeatureDefinition featdef in dd)

            {

                try

                {

                    Console.WriteLine(featdef.RootDirectory + "-------" + featdef.Id.ToString() + "-------" + featdef.GetTitle(System.Threading.Thread.CurrentThread.CurrentCulture));

                }

                catch

                {

 

                    //This code will be executed if the feature does not have the manifest file.

                    Console.WriteLine("################################################");

                    Console.WriteLine("Error Ocurrred! Attempting to get feature ID of the feature without manifest file...:");

                    Console.WriteLine(featdef.Id.ToString());

                }

                finally

                {

                    Console.WriteLine();

                    Console.WriteLine("Press enter to view next feature");

                    Console.ReadLine();

                }

            }

如果出问题,可以使用

C:\>stsadm.exe -o uninstallfeature -id <id> –force 卸载 

 

 http://blogs.msdn.com/b/tehnoonr/archive/2009/02/15/resolving-the-error-failed-to-find-the-xml-file-at-location-12-template-features-feature-name-feature-xml.aspx

Introduction

If you install a feature in your MOSS 2007 farm and after that the feature folder or the feature manifest file accidently gets deleted from your Web Front End servers file system, you will get the error "Failed to find the XML file at location '12\Template\Features\Feature_Name\feature.xml" when you go to Site Settings --> Galleries --> Workflows. This is because your feature is still installed in the farm, and when you view the workflow gallery page, the page will go through all the features installed in your farm, and then read their corresponding manifest files from the file system to determine if the feature has a corresponding workflow associated to it. If the feature is installed and the corresponding manifest file has been deleted, this error will be thrown.

 Possible Causes of the Error

There are a couple of reasons (that I can think of) why you might get this error:

  1. Your current MOSS 2007 farm is an upgrade from a previous version (MOSS beta or SPS 2003). Some features were part of the previus version of MOSS but now have been deprecated.
  2. You installed the feature in your farm and accidently deleted the feature manifest file from the file system of the web front end server. Feature folders are located at "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\FEATURES".

 Resolving the Error

There are two possible resolutions to this problem:

1. If you have the original feature manifest file and the feature folder, just copy that entire folder back on the file system of all web front end servers at the path mentioned above (C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\FEATURES). Ask developers on your team if they have deployed any features in the farm and get the manifest file from them if you don't have them.

2. This second resolution is for the scenario if you have completely lost the feature manifest file, or if the feature was in an older version of MOSS, and now you have upgraded your MOSS farm and the feature has been deprecated. The only way out in this situation is to uninstall the feature using an stsadm comand. Normally, you can uninstall features by using the feature name and stsadm, but in this situation, because there is no feature manifest available, you will have to uninstall the feature using the feature GUID. Following is a sample code that you can use to figure out the GUID of the feature that has a missing manifest file. Just put this into a C# Cosole Application and execute on your web front end server:

   List<Guid> featIDs = new List<Guid>();
            foreach (SPFeatureDefinition featdef in SPFarm.Local.FeatureDefinitions)
            {
                try
                {
                    Console.WriteLine(featdef.RootDirectory + "-------" + featdef.Id.ToString() + "-------" + featdef.GetTitle(System.Threading.Thread.CurrentThread.CurrentCulture));
                }
                catch
                {

                    //This code will be executed if the feature does not have the manifest file.
                    Console.WriteLine("################################################");
                    Console.WriteLine("Error Ocurrred! Attempting to get feature ID of the feature without manifest file...:");
                    Console.WriteLine(featdef.Id.ToString());
                 }
                finally
                {
                    Console.WriteLine();
                    Console.WriteLine("Press enter to view next feature");
                    Console.ReadLine();
                }

          }

 Once you have the feature GUID, you can use the following stsadm command to get rid of this feature:

stsadm.exe -o uninstallfeature -id <feature_giud> -force.

Once you do this, we should be good! 

 

 

 

 

posted @ 2012-02-24 09:34  邑尘  阅读(678)  评论(0编辑  收藏  举报