Monday, January 20, 2014

How to resolve "Missing server side dependencies - MissingSetupFile and MissingWebPart" error

It's quite possible to get these two errors for any SharePoint developer. It's annoying because we don't get the exact location of the problem! What is the web URL? Which page throw out these errors? I wonder why Microsoft don't want to tell us directly.

However, all settings are stored in database. It's quite easy to figure it out. We don't need to modify any data directly, the problem can be fixed through SharePoint "Site Settings" page.

Below is the "MissingSetupFile" error message I got recently.

[MissingSetupFile] File [Features\WebPart.Feature1_Feature1\Feature1\Feature1.webpart] is referenced [1] times in the database [SP_Content_80], but is not installed on the current farm. Please install any feature/solution which contains this file. One or more setup files are referenced in the database [SP_Content_80], but are not installed on the current farm. Please install any feature or solution which contains these files. 

From this error message, we got the feature path and the content database name. So we can use SQL Server Management Studio to connect to the database instance, and then run the script below.

use SP_Content_80;

SELECT AllSites.PortalURL AS SiteUrl, AllWebs.FullUrl AS WebUrl, DirName, LeafName, AllDocs.DeleteTransactionId from AllDocs
 INNER JOIN AllSites ON AllDocs.SiteId = AllSites.Id
 INNER JOIN AllWebs ON AllDocs.WebId = AllWebs.Id
 WHERE SetupPath = 'Features\WebPart.Feature1_Feature1\Feature1\Feature1.webpart'

Now, we know which site throw out the error. We know this web part is not installed on the SharePoint web front end server properly. So we need to go to "Site Settings -> Galleries -> Web parts", and then delete the corrupted web part there. Don't forget to delete it from site recycle bin and site collection recycle bin!

Another famous error is "MissingWebPart". Below is the error message.

[MissingWebPart] WebPart class [179980ae-7af7-e8b8-5d0d-3b52c4e355c7] (class [Company.WebPart1] from assembly [Company.WebPart1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ee2933e44bf984ce]) is referenced [2] times in the database [SP_Content_80], but is not installed on the current farm. Please install any feature/solution which contains this web part. One or more web parts are referenced in the database [SP_Content_80], but are not installed on the current farm. Please install any feature or solution which contains these web parts. 

Similarly, we can run the script below.

use SP_Content_80;

select AllSites.PortalURL AS SiteUrl, AllWebs.FullUrl AS WebUrl, DirName, LeafName, AllWebParts.tp_Assembly, AllWebParts.tp_ZoneID from AllDocs
 INNER JOIN AllSites ON AllDocs.SiteId = AllSites.Id
 INNER JOIN AllWebs ON AllDocs.WebId = AllWebs.Id
 INNER JOIN AllWebParts ON AllDocs.Id = AllWebParts.tp_PageUrlID
where AllWebParts.tp_WebPartTypeId = '179980ae-7af7-e8b8-5d0d-3b52c4e355c7'

Now we can open the page through web browser, and then delete(not close!) the web part from the page.


References:

http://get-spscripts.com/2011/08/diagnose-missingwebpart-and.html

No comments:

Post a Comment