Data at the root level is invalid

So, last week I encountered the dreaded “Data at the root level is invalid” error when trying to re-deploy an existing solution to Sharepoint 2010. I have a standard way of deploying via generig command and PS files and the deployment worked multiple times before. However, between the last time I deployed something and this error I have made multiple changes to my Sharepoint 2010 environment.

My PS looks like this:

“function WaitForJobToFinish([string]$SolutionFileName) {     $JobName = “*solution-deployment*$SolutionFileName*”     $job = Get-SPTimerJob | ?{ $_.Name -like $JobName }     if ($job -eq $null)     {         Write-Host ‘Timer job not found’     }     else     {         $JobFullName = $job.Name         Write-Host -NoNewLine “Waiting to finish job $JobFullName”                 while ((Get-SPTimerJob $JobFullName) -ne $null)         {             Write-Host -NoNewLine .             Start-Sleep -Seconds 2         }         Write-Host  “Finished waiting for job..”     } }

Add-PsSnapin Microsoft.SharePoint.PowerShell

  $CurrentDir=$args[0] $solutionName=$args[1] $featurename=$args[2] $sitecollection=$args[3] $SolutionPath=$CurrentDir + “\”+$solutionName

Write-Host ‘Solution Name:’ $args[1] Write-Host ‘Feature Name:’ $featurename Write-Host ‘Site Collection:’ $args[3]

  Write-Host ‘Going to disable feature’ disable-spfeature -identity $featurename -confirm:$false -url $sitecollection   Write-Host ‘Going to uninstall feature’ uninstall-spfeature -identity $featurename -confirm:$false -force   Write-Host ‘Going to uninstall solution’ Uninstall-SPSolution -identity $solutionName  -allwebapplications -confirm:$false

Write-Host ‘Waiting for job to finish’ WaitForJobToFinish

Write-Host ‘Going to remove solution’ Remove-SPSolution –identity $solutionName -confirm:$false   Write-Host ‘Going to add solution’ Add-SPSolution $SolutionPath   Write-Host ‘Going to install solution to all web applications’ Install-SPSolution –identity $solutionName –webapplication $sitecollection -GACDeployment

Write-Host ‘Waiting for job to finish’ WaitForJobToFinish

Write-Host ‘Going to enable Feature’ Enable-spfeature -identity $featurename -confirm:$false -url $sitecollection

Remove-PsSnapin Microsoft.SharePoint.PowerShell”

The process fails when I call the Add-SPSolution line with “…Data at the root level is invalid…”. As most should know this error happens when an XML file is not formed properly and in Sharepoint’s case probably a web.config file. Because the incorrect file is “out of” normal Sharepoint use the order gives no more information as to where the problem is.

The only real direction from a Google search shows an issues with _vti_cnf folder created by Sharepoint Designer. This seems to be the most common problem and easily solved by just deleting all _vti_cnf folders in your Sharepoint environment (typically under Inetpub folder). Unfortunately did not work for me as there were no _vti_cnf folders.

So to try and solve I checked, deleted some web.config files, reset my custom Master pages to default etc. I even did a repair on my Sharepoint installation. I finally solved by copying the XML folder (C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\XML) on one of the servers in the farm to the application server and this solved the issues. Probably not the safest thing to do, but desperate times calls for desperate measures. I can vageuly remember making a change to the wss.xsd file in this folder when I had a problem saving a site as a site template, so be carefull when editing non configuration Sharepoint files.

Leave a Reply

Your email address will not be published. Required fields are marked *