上次修改时间: 2010年7月7日
适用范围: SharePoint Server 2010
若要将 .NET 连接程序集导入到 BDC 元数据存储中,请执行以下步骤。
导入空 BDC 模型。.NET 程序集必须存在于 BDC 元数据存储的 LobSystem 中。因此,在导入程序集之前,必须使用 SharePoint 管理中心来创建空 BDC 模型并将其导入到 BDC 中。
您在此处指定的 LobSystem 名称将是用户在尝试创建外部内容类型时在 Microsoft SharePoint Designer 2010 中将看到的内容。
将以下模型复制到文本文件中,然后将其另存为 XML(例如 c:\InitialModel.xml)。
<?xml version="1.0" encoding="utf-8" standalone="yes"?> <Model xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://schemas.microsoft.com/windows/2007/BusinessDataCatalog BDCMetadata.xsd" xmlns="https://schemas.microsoft.com/windows/2007/BusinessDataCatalog" Name="DotNetAssembly_Model"> <LobSystems> <LobSystem Name="ExchangeSample" Type="DotNetAssembly"> <LobSystemInstances> <LobSystemInstance Name="MyLSI"> </LobSystemInstance> </LobSystemInstances> </LobSystem> </LobSystems> </Model>按管理 BDC 模型中的说明导入模型。
在 BDC 元数据存储中有模型后,执行 Import-SPBusinessDataCatalogDotNetAssemblyWindows PowerShell 命令以导入主 .NET 程序集及其依赖程序集。
打开 SharePoint Management Shell。首先,执行命令以从管理元数据目录中获取 LobSystem。然后,执行 SPBusinessDataCatalogDotNetAssembly cmdlet,如下面的示例中所示:
C:\PS>$site = new-object "Microsoft.SharePoint.SPSite" "http://<yourSiteName>"
C:\PS>$serviceContext = [Microsoft.SharePoint.SPServiceContext]::GetContext($site)
C:\PS>$bdcService = new-object "Microsoft.SharePoint.BusinessData.SharedService.BdcService"
C:\PS>$catalog = $bdcService.GetAdministrationMetadataCatalog($serviceContext)
C:\PS>$lobsystem = $catalog.GetLobSystem("ExchangeSample")
C:\PS> Import–SPBusinessDataCatalogDotNetAssembly –LobSystem $lobsystem –Path "c:\ExchangeIntegrationAssembly.dll"Import-SPBusinessDataCatalogDotNetAssembly 命令具有以下语法:
Import-SPBusinessDataCatalogDotNetAssembly –LobSystem $lobsystem –path <string> -DependentAssemblyPaths <string list>
以下是使用不同程序集的示例。
C:\PS> Import–SPBusinessDataCatalogDotNetAssembly –LobSystem $lobsystem –Path "c:\Folder\Assembly.dll" –DependentAssemblyPaths "c:\Folder\Assembly2.dll","c:\Folder\Assembly3.dll"
备注
从 BDC 模型引用的类型必须在主程序集中进行定义。依赖程序集通常用于帮助程序方法或实用工具函数。
重新启动 Internet Information Service(如果需要)。如果在导入程序集后更改它,则将需要在执行 Import–SPBusinessDataCatalogDotNetAssembly 命令后重新启动 IIS。首次导入模型时不需要这样做。