Error 0x80131600 when creating external list for bcs in sharepoint

1

How can I get the creation of external lists to work from a powershell script?

I have a solution that I am deploying to a SharePoint 2010 server using a rather large powershell script. When the script is about to create the external list using a BCS model as it's data source I get the exception <nativehr>0x80131600</nativehr><nativestack></nativestack>

Here is an excerpt from the powershell code that is used to create the list:

# Remove the BCS model.
# Deploy the WSP package, including the BCS model.
# Delete the external list if it already exists.
...
$currentEntityName = $Entity.Name
Write-Host "BCS: Entity '$currentEntityName' - Granting permissions"
Grant-SPBusinessDataCatalogMetadataObject -Identity $Entity -Right $EntityPermissions -Principal $principal -ErrorAction SilentlyContinue
Grant-SPBusinessDataCatalogMetadataObject -Identity $Entity -Right $EntityPermissions -Principal $principalAllFlisUsers -ErrorAction SilentlyContinue
Grant-SPBusinessDataCatalogMetadataObject -Identity $Entity -Right $EntityPermissions -Principal $principalAllFlisUsersDemo -ErrorAction SilentlyContinue
Grant-SPBusinessDataCatalogMetadataObject -Identity $Entity -Right $EntityPermissions -Principal $principalAppPoolUser -ErrorAction SilentlyContinue
...
$ds = New-Object -TypeName Microsoft.SharePoint.SPListDataSource 
$ds.SetProperty("LobSystemInstance", $instanceName) 
$ds.SetProperty("EntityNamespace", $ns) 
$ds.SetProperty("Entity", $name) 
$ds.SetProperty("SpecificFinder", $sf.Name) 
...         
$site = Get-SPSite -Identity $SiteUrl 
$web = $site.OpenWeb($webNameString) 

$newList = $web.Lists.TryGetList("$ExternalListName")
if (!$newList)
{
    $ListGUID = $web.Lists.Add("$ExternalListName", "", [String]::Format($ListUrl, $ExternalListUrl), $ds) | out-null
    $web.Lists[$ListGUID].Update()
    $web.Update()
}

The exception is thrown when I call the $web.Lists.Add() method near the end.

In the ULS-log I have found an exception that might be related:

The type '        ProjectName.Common.CustomFieldTypes.ListSpecificCustomField,ProjectName, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ff8505e11ea28a7e      ' could not be deserialized. Exception: System.TypeLoadException: Could not load type 'ProjectName.Common.CustomFieldTypes.ListSpecificCustomField' from assembly 'ProjectName, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ff8505e11ea28a7e      '.     at System.RuntimeTypeHandle._GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, Boolean loadTypeFromPartialName) ...

(Note: I have replaced the actual project name with ProjcetName and replaced the name of the custom field)

The list is visible in the /_layouts/sitemanager.aspx but it does not show any data. When a powershell script is testing if it exists already, the test returns true.

The odd thing is when I re-run the whole powershell script the list is created correctly. It is however not enough to just loop the quoted script lines in order to get a correct deploy. This leads me to think that either the BCS-model is not completely deployed or the BCS model is somehow cached and is resistant to change while the deployment script is running.

powershell
sharepoint-2010
bcs
asked on Stack Overflow Apr 11, 2013 by Svanberg

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0