STSADM -o export: FatalError: Failed to compare two elements in the array


Community Update

It’s nice to see the community providing feedback on my tools and improving them. I strongly encourage this and here’s another example of this kind of interaction.

Achim Ismaili has improved the FaultyFeatureTool and added it to codeplex: http://featureadmin.codeplex.com/

Be sure to check it out !

Problem

Using the STSADM.EXE tool for exporting a Site Collection to a file may result in the following error in the log file

[8/23/2007 9:24:56 AM]: Start Time: 8/23/2007 9:24:56 AM.
[8/23/2007 9:24:56 AM]: Progress: Initializing Export.
[8/23/2007 9:24:57 AM]: Progress: Starting Export.
[8/23/2007 9:24:57 AM]: Progress: Calculating Objects to Export.
[8/23/2007 9:25:00 AM]: Progress: Serializing Objects to Disk.
[8/23/2007 9:25:00 AM]: Progress: Starting to process objects of type Site.
[8/23/2007 9:25:01 AM]: Progress: Finished processing objects of type Site.
[8/23/2007 9:25:01 AM]: Progress: Starting to process objects of type Web.
[8/23/2007 9:25:01 AM]: Progress: Exporting Web http://moss2007dev.
[8/23/2007 9:25:01 AM]: FatalError: Failed to compare two elements in the array.
   at System.Collections.Generic.ArraySortHelper`1.QuickSort[TValue](T[] keys, TValue[] values, Int32 left, Int32 right, IComparer`1 comparer)
   at System.Collections.Generic.ArraySortHelper`1.QuickSort[TValue](T[] keys, TValue[] values, Int32 left, Int32 right, IComparer`1 comparer)
   at System.Collections.Generic.ArraySortHelper`1.QuickSort[TValue](T[] keys, TValue[] values, Int32 left, Int32 right, IComparer`1 comparer)
   at System.Collections.Generic.ArraySortHelper`1.Sort[TValue](T[] keys, TValue[] values, Int32 index, Int32 length, IComparer`1 comparer)
   at System.Collections.Generic.ArraySortHelper`1.Sort(T[] items, Int32 index, Int32 length, IComparer`1 comparer)
   at System.Array.Sort[T](T[] array, Int32 index, Int32 length, IComparer`1 comparer)
   at System.Collections.Generic.List`1.Sort(Int32 index, Int32 count, IComparer`1 comparer)
   at System.Collections.Generic.List`1.Sort(IComparer`1 comparer)
   at Microsoft.SharePoint.Deployment.WebSerializer.GetDataFromObjectModel(Object obj, SerializationInfo info, StreamingContext context)
   at Microsoft.SharePoint.Deployment.DeploymentSerializationSurrogate.GetObjectData(Object obj, SerializationInfo info, StreamingContext context)
   at Microsoft.SharePoint.Deployment.XmlFormatter.SerializeObject(Object obj, ISerializationSurrogate surrogate, String elementName, Boolean bNeedEnvelope)
   at Microsoft.SharePoint.Deployment.XmlFormatter.Serialize(Stream serializationStream, Object topLevelObject)
   at Microsoft.SharePoint.Deployment.ObjectSerializer.Serialize(DeploymentObject deployObject, Stream serializationStream)
   at Microsoft.SharePoint.Deployment.SPExport.SerializeObjects()
   at Microsoft.SharePoint.Deployment.SPExport.Run()
*** Inner exception:
Object reference not set to an instance of an object.
   at Microsoft.SharePoint.SPFeature.EnsureProperties()
   at Microsoft.SharePoint.SPFeature.get_TimeActivated()
   at Microsoft.SharePoint.Deployment.WebSerializer.ExportFeatureComparer.System.Collections. Generic.IComparer<Microsoft.SharePoint.Deployment.ExportObject>.Compare(ExportObject exportObject1, ExportObject exportObject2)
   at System.Collections.Generic.ArraySortHelper`1.QuickSort[TValue](T[] keys, TValue[] values, Int32 left, Int32 right, IComparer`1 comparer)
[8/23/2007 9:25:01 AM]: Progress: Export Completed.
[8/23/2007 9:25:01 AM]: Finish Time: 8/23/2007 9:25:01 AM.
[8/23/2007 9:25:01 AM]: Completed with 0 warnings.
[8/23/2007 9:25:01 AM]: Completed with 1 errors.

Cause

In my case the cause was an invalid Feature registration in the Site Collection (SPSite) or root Site (SPWeb).

Solution

I have written a small tool to enumerate all features of a site and its site collection. When you find an invalid feature you can delete it using the Feature ID and STSADM.

Usage

Run the tool locally on the SharePoint Server and enter the URL to the problematic site (in my case the root site). When a valid feature is returned you will get the Feature Title and the Feature Id. When an invalid feature is returned you will only get the Feature Id.

Use the Feature Id in the STSADM tool to force remove the feature:

eg. STSADM -o deactivatefeature -id 11cda100-5a8c-4f39-a149-0fd3f86b5e98 -url http://localhost -force

Afterwards you can run the tool again to verify if the feature is removed. You should now be able to export the site collection... At least I was...

Screenshot

Applies to

Windows SharePoint Services 3.0, Microsoft Office SharePoint Server 2007 (because of the use of the Feature Framework)

Download

 


Comments

Thursday, 27 Dec 2007 07:53 by Wyn
Excellent that you made this tool!! Exactly what I needed and saved so much time.

Thursday, 27 Dec 2007 07:53 by S.S. A
Hi Steven, Thank you very much! I am glad to hear from you. Yes, I have some interesting stuff lined up, and I am excited about it. Mostly I will publish small tips that would be helpful to the developer community. Thanks once again. Regards, S.S. A p.s I am sorry I couldn't find a link on your blog to send you an email, therefore, I am adding this comment.

Thursday, 27 Dec 2007 07:53 by Steven Van de Craen
I have finalized the Contact Form. From now on you can contact me using the contact.aspx page ;)

Thursday, 27 Dec 2007 07:53 by Nigel
Hi Steven - I have run your tool and it works great ! - however, I have a problem - your tool reports an invalid feature at a web which not the root web eg :- http://myweb.com/thisweb and I cant remove it using stsadm as suggested as it says you must remove it from the root site - which I did - but your tool still reports the error in the sub site Nigel

Thursday, 27 Dec 2007 07:53 by Steven Van de Craen

Hi Nigel,

I did some testing and it was not possible using STSADM. I have released a newer version of the tool that should let you delete the features instantly. Be careful ! This tool will delete *any* feature you select, also working ones.

Steven


Thursday, 27 Dec 2007 07:53 by Babak
I've been researching this 'Object reference not set to an instance of an object' error when I try to deploy my Webpart via Visual Studio 2005 for over a week now. This tool has been the only helpful item I've found anywhere on the web relating to this issue. I ran the tool, removed the corrupt feature, and the deployment worked for the first time in a week.

Thursday, 27 Dec 2007 07:53 by Aries
Hi Steve, I can't backup my site after I installing some feature and almost getting upset about it. Your post so helpful. Really thanks ^^

Thursday, 27 Dec 2007 07:53 by Serge van den Oever [Macaw]
Hi Steven, thanks for this great tool. I was completely stuck developing my own tool for exporting SharePoint content using SPExport. I could never have quessed that a faulty feature was the reason that I got the "Failed to compare two elements in the array" exception. I will add this to my toolbox, and drink a beer on your health tonight!! Serge

Thursday, 27 Dec 2007 07:53 by Norm Smith
Great little tool. Simple, Straightforward, no gimmicks - Problem Solved!!! Thank you!

Thursday, 27 Dec 2007 07:53 by David Dean
Thanks a bunch for your post and your utility, Steven. This was exactly my problem and saved me a bunch of head-scratching.

Thursday, 27 Dec 2007 07:53 by Mel Alberti
Hi Steven, this sounds like a great tool. I'm trying to run it on my local SharePoint install but am getting the infamous "Request for the permission of type 'Microsoft.SharePoint.Security.SharePointPermission, Microsoft.SharePoint.Security, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' failed" error. I tried setting the trust setting in web.config for my virtual server to "Full" and did an iisreset, but I still see the error. Is there something else I need to do at the server or SharePoint level to get rid of this error? Thanks!

Thursday, 27 Dec 2007 07:53 by Mel Alberti
Well, just answered my own question. I was running this tool from a network drive. As soon as I moved it to the local C: drive, it works fine (with "Full" trust access).

Thursday, 27 Dec 2007 07:53 by Guillermo Pussetto
Hi, I have exactly the same problem, run your tool and voila! errors gone. Thanks a lot G

Thursday, 27 Dec 2007 07:53 by mela
Hi steve! when i ran your tool and there were a lot of error feature. TUrns out there were enterprise feature but we are running on standard edition. the site was migrated to our standard edition. however, when i removed the feature and run the export tools again, there were still error main because the site perhaps may be using the features i uninstalled. any thoughts on what i should do now?

Thursday, 27 Dec 2007 07:53 by Steven Van de Craen
Mela, I don't know what other causes this exception could have, but if it is not solved by removing the features I can't really help you any further. Does the tool still give you errors on certain (site collection or site) features ?

Thursday, 27 Dec 2007 07:53 by mela
hi steven! one of the features that the tool recognized as an error was IPFSWebFeatures (i knew what the feature was after searching that GUID on google). i tried to uninstall it, but when i exported again, it is now looking for this feature also. i tried to install this feature again but again i am again having the error: Failed to compare two elements in the array.

Thursday, 27 Dec 2007 07:53 by merav
thanks a lottttt

Thursday, 27 Dec 2007 07:53 by Phill Duffy
Thank you so much, a very useful tool indeed and a big thank you for the source code too it.

Thursday, 27 Dec 2007 07:53 by David Remillard
Thanks a lot for this. I've been struggling with this issue for a couple days now. Very much appreciated!

Thursday, 27 Dec 2007 07:53 by Hexane
This was huge. Helped me get past my issue with this. /me tucks this tool away in my toolbox.

Thursday, 27 Dec 2007 07:53 by Etienne Lambert
Steve, you're the man. Thank you for the tool & code!!!

Thursday, 27 Dec 2007 07:53 by Alan
Great tool! Fixed the problem. Thanks

Sunday, 13 Jan 2008 04:08 by Casey
This tool worked great for me, my only concern is that I deleted features that I need - would that be true? Is it safe to assume that any errors removed would not be working anyway and being currently used in a production environment?

Friday, 18 Jan 2008 05:24 by Steven Van de Craen
I think most of the erroneous features are leftovers from B2TR upgrades or incorrect removed development features. I couldn't see how one of the OOTB features would be corrupted (unless someone deleted the folder in \FEATURES). You could always reactivate the current set of features so that any (hidden) feature dependencies are loaded again just to be safe.

Friday, 25 Jan 2008 08:15 by PhilB
Great tool but I got this on export: Feature 'a0e5a010-1329-49d4-9e09-f280cdbed37d' for list template '10102' is not installed in this farm. The operation could not be completed. Better than before but now what? Ideas welcome. PB

Sunday, 24 Feb 2008 12:12 by Molay Ash
Great tool.It was creating error (Object reference not set to an instance of an object) when I try to deploy my Webpart via Visual Studio 2005 . After removing the particular feature by using this tool the problem has been solved.I think it's the only tool to solve this kind of "Life Hell" error. Thanks

Wednesday, 27 Feb 2008 03:31 by Pete Halverson
Thanks so much, bailed me out of an important migration task. Love it when Googling the problem takes you right to solution!

Tuesday, 18 Mar 2008 07:49 by Bray
Seriously- Good job buddy.

Friday, 21 Mar 2008 03:25 by bgeoffro (MCS)
Great tool. Helped me resolve export issues with sites that had been migrated from a MOSS Enterprise environment to a MOSS Standard environment. One minor issue - the tool only seemed able to remove one feature at each scope (i.e. 1 SPSite-scoped feature and 1 SPWeb-scoped feature or one of either) at a time, even though I had multiple features selected. Is this by design, or a bug?

Sunday, 23 Mar 2008 05:40 by Barry Hohstadt
HI, and thanks for all your work. I ran into a export fatal error though after removing the invalid features: "FatalError: Feature 'a0e5a010-1329-49d4-9e09-f280cdbed37d' for list template '10102' is not installed in this farm. The operation could not be completed." I am now afraid I may have screwed something up, maybe to do with a customized list that was developed for us? Any ideas how to correct? Thanks

Monday, 24 Mar 2008 10:59 by Steven Van de Craen
The tool should be able to remove multiple features at a same time and if it doesn't it is probably a bug.

Monday, 24 Mar 2008 11:01 by Steven Van de Craen
Barry, If you have the custom list solution/feature I suggest you try to force reinstall it. Or if you don't need it anymore you could remove all the bits (like the list template) manually yourself.

Tuesday, 8 Apr 2008 08:03 by Shola Salako
Awesome tool, Steven! Thanks for sharing! Barry, I ran into the same problem. a0e5a010-1329-49d4-9e09-f280cdbed37d corresponds to the IPFSWebFeatures on my server. I reinstalled it using the following command: stsadm -o installfeature -name IPFSWebFeatures -force and I was able to export my sites. I hope this helps you. I was initially trying to create a site template of my sites without the content - this was what led me to using the stsadm export function. I was getting "Failure decompressing data from a cabinet file" errors when I attempted to do this via the SharePoint site interface. Well, I was able to fix this problem also using the Faulty Feature tool. Thanks, Shola Salako

Thursday, 17 Apr 2008 08:08 by SAM
Hi Steve, cool Blog. I am facing exactly this Problem. My question is now: Will the name of the Feature be empty -> like... Feature: 11cda100-5a8c-4f39-a149-0fd3f86b5e98() or is it something like -> Feature: 11cda100-5a8c-4f39-a149-0fd3f86b5e98(CTypes) or (NoCodeWorkflow) ? Thanks for your Help Sam

Monday, 28 Apr 2008 10:53 by Steven Van de Craen
I've fixed the issue where only 1 checked feature would be deleted. Now you can delete multiple checked features at once ! @SAM: Normally each feature has a name. If the feature doesn't exist it will still give you the GUID but also an error notification.

Sunday, 4 May 2008 03:56 by Srikanth G
Hey Steve, How wonderful tool it is. I have struggled a lot to get rid of this error. It was fortunate that I could find this. I could remove all the ERROR READING FEATURE features from the subwebs (sub sites) and could export the bugging site collection.

Wednesday, 21 May 2008 06:40 by Said
You Rock, Steven :-)

Thursday, 3 Jul 2008 06:17 by aey
Thank youo so much.This is great tools for solve my problem.

Thursday, 31 Jul 2008 02:49 by atilia
great tool - thanks for that!

Friday, 22 Aug 2008 10:17 by Peter
Fantastic tool and it works perfectly! Tnx. Would you be so kond and answer this: I have a site collection with hundreds of sub sites. It seems I have to remove the invalid features from sites one by one. Is there any way to remove the features on subsites at once?

Monday, 25 Aug 2008 10:06 by Steven Van de Craen
Peter, if you know how to code you can extend the tool and recurse all subsites or poor the code into a custom STSADM command.

Monday, 8 Sep 2008 11:47 by Raj
Steven, how could we indentify the faulty features. By running the tool, it gives "Error reading...[feature id]" for some features. Are these features the ones that needs to be removed. Moreover, how could we confirm that we do not remove any important feature during this process. In case, we did remove any important and required feature, is there any possible way to revert back things.

Tuesday, 9 Sep 2008 10:12 by Steven Van de Craen
Raj, if it gives the 'Error reading' it means that that feature is active on the web but not installed on the server(s). Either remove it via my tool or try to Google the ID and see where the feature belongs to. If it is a third party component you might try reinstalling that to solve the issue.

Tuesday, 9 Sep 2008 05:22 by Zakaria Salim
Excellent tool, it has saved my live. Keep up the good work! ZS

Tuesday, 9 Sep 2008 05:47 by Raj
Thanks Steven. I managed to remove most, but somehow left two fault features in a sub site. Unknowingly, I ran the export once again. But this stime it showed me a different inner exception. It says "Object reference not set to an instance of an object." Earlier the inner exception used to say "Failed to find the XML file at location". I ran the tool in the sub site stated and found two faulty features. As you mentioned I cross checked the Feature Id in google, just to find that one of them is used for "E-mailing a Document from a SharePoint Document Library." So, I believe I could not remove it.Should I? Please guide me the way to resolve the issue in hand and make me able to export.

Wednesday, 10 Sep 2008 09:06 by Steven Van de Craen
Raj, if you are referring to this custom feature (http://www.beckybertram.com/oldblog/index.php?p=31&more=1&c=1&tb=1&pb=1) then it is no standard feature and can be removed with the tool. Otherwise try to deploy the package containing that feature again. Since you have the web url and feature id you could also remove (force) it with STSADM.

Monday, 15 Sep 2008 01:25 by Ramadan Abu Ghosh
Thanks steven for the effort. I first came across the following error when trying to export my sharepoint site: FatalError: Failed to compare two elements in the array. i have removed the faulty features, but this lead to another error when exporting: FatalError: Feature 'a0e5a010-1329-49d4-9e09-f280cdbed37d' for list template '10102' is not installed in this farm I have done the following steps to rollback the removed feature: stsadm -o installfeature -name IPFSWebFeatures -force stsadm -o activatefeature -id a0e5a010-1329-49d4-9e09-f280cdbed37d -url http://[Web] -force then doing the export operation again showed me the original error: FatalError: Failed to compare two elements in the array. but this time it showed me the site causing this problem, the solution was for me to delete this site and things went fine after that

Wednesday, 1 Oct 2008 10:53 by Hal Diggs
just what I needed.

Monday, 6 Oct 2008 04:14 by César
just perfect :)

Thursday, 16 Oct 2008 08:08 by Vince Rothwell
Steven, Thanks a lot...really help me. --Vince

Saturday, 25 Oct 2008 11:36 by Daniel Bugday
Thanks a lot Steven! Would be nice to have a tool that does the same when importing a site collection with missing features :) Cheers

Wednesday, 12 Nov 2008 02:13 by JM
Thanks - your tool worked a treat.

Monday, 1 Dec 2008 05:10 by Nandita
Thanks alot; worked like a charm

Monday, 22 Dec 2008 10:16 by Matthew
I LOVE SMART PEOPLE!!! There aren't enough of you in this world.

Tuesday, 3 Feb 2009 04:55 by Rick
Love the tool!

Friday, 6 Feb 2009 05:19 by Ayoub Umoru
Thank you very much. It helped me a lot. Nice and smart tool for that what i needed ;)

Friday, 6 Feb 2009 05:22 by Ayoub Umoru
Thank you very much. It helped me a lot. Nice and smart tool for that what i needed ;) I changed the log output a bit to see the feature name. In BuildFeatureLog Old sb.AppendLine(feature.ToString()); New sb.AppendLine(feature.ToString() + " " + feature.Name);

Tuesday, 17 Feb 2009 02:28 by Ralph de Ruijter
Thanks Steve, your tool was a great help fixing my sharepoint problems.

Wednesday, 1 Apr 2009 03:53 by Dave Dykshoorn
Awesome, cleaned up my dev box so I could do some useful work. Saved me a ton of time.

Thursday, 7 May 2009 07:11 by Jason
Thank you! :)

Thursday, 28 May 2009 03:34 by Scott
You Rock!

Monday, 22 Jun 2009 08:01 by Abid
Thanx for this wonderful tool steve :)

Tuesday, 30 Jun 2009 10:31 by Chad
We used it on a content migration, invaluable!

Tuesday, 28 Jul 2009 08:37 by
Hi, I have used this tool for removing the invalid features. But it is still giving me the error "Failed to compare two elements in the array". I am taking back up through SPD. Please Help

Friday, 18 Sep 2009 12:58 by Bart Snyckers
Great tool, thank you. Solved my problem instantly!

Wednesday, 4 Nov 2009 04:45 by Eddy Rocket
Holly crap!!! You are amazing man!!!! I've just saved nearly 7 days of work thanks to this tool. Keep on doing that great job dude!!!!

Monday, 26 Apr 2010 09:15 by Mohammed
U R The Best . thanks

Monday, 14 Jun 2010 12:14 by Vipul Kothari
Thanks man it was awesome.

Tuesday, 27 Jul 2010 06:52 by Abhishek
Mike, Can we use this tool to remove the OOB enterprise features like DataConnectionLibrary , bizappslisttemplate etc? the reason i am asking this Q is because I have requirement to migrate from enterprise to std MOSS 2007. My import fails because of the feature missing. I want to use ur tool to remove from source and then export. Thanks in advance...

Wednesday, 28 Jul 2010 07:47 by Steven Van de Craen
Abishek, you can use this tool to remove any feature from the source.

Thursday, 25 Nov 2010 01:56 by Kishore
Simply Excellent tool,.... It saved my day

Monday, 23 Jul 2012 08:30 by Shae
Much appreciated!

Wednesday, 29 May 2013 01:55 by Paulo
Fantastic the best tool.

Tuesday, 5 Nov 2013 03:19 by Franz
Great tool (vs2.3 2007) Thanks!!!

CAPTCHA Image Validation