giovedì 18 luglio 2013

Sharepoint 2013 - Content Query Web Part : System.ArgumentNullException: Key cannot be null. Parameter name: key

Problema:
System.ArgumentNullException: Key cannot be null. Parameter name: key at System.Collections.SortedList.IndexOfKey(Object key) at System.Collections.SortedList.ContainsKey(Object key) at Microsoft.SharePoint.Publishing.WebControls.ContentByQueryToolPart.AppendListTypes(SortedList sortedListItems, SPListTemplateCollection listTypes) at Microsoft.SharePoint.Publishing.WebControls.ContentByQueryToolPart.populateListTypeDropDown() at Microsoft.SharePoint.Publishing.WebControls.ContentByQueryToolPart.populateCBQControls() at Microsoft.SharePoint.Publishing.WebControls.ContentByQueryToolPart.OnPreRender(EventArgs e)

Descrizione:
Il controllo Microsoft.SharePoint.Publishing.WebControls.ContentByQueryToolPart ha un metodo privato populateListTypeDropDown che chiama il metodo GetCurrentListTemplates da SPWeb.ListTemplates che ritorna una PListTemplateCollection.
Nel metodo AppendListTypes vengono aggiunte i tipi attraverso una chiamata a ContainsKey della proprietà Name. Se esiste un template senza nome viene ritornata l'eccezione qui sopra.
Soluzione:

Recuperare i template che non hanno nome
(Get-SpWeb https://url).ListTemplates | ? {$_.Name -eq $null }

Disabilitare le feature che installano questi template:

Disable-SPFeature -Identity e374875e-06b6-11e0-b0fa-57f5dfd72085 -Url https://url
Ovviamente occorre verificare che la feature non sia fondamentale :=)

Nessun commento:

Posta un commento