0

更新

值得注意的是,仅当从 SPWebApplication.Sites.Add 调用站点定义时才会发生这种情况,如果我使用 UI 则可以正常工作。调用此代码时,我的代码正在模拟系统帐户。

我是否认为 SPSite 的 ApplyWebTemplate() 方法是异步的?如果是这种情况,那么我的问题可能是时间问题之一。即,运行此代码时所需的基础设施尚未到位。

原始问题

我有一个自定义网站定义,它使用 SPProvisioningProvider 来配置网站集。

在调用 ApplyWebTemplate("BLANKINTERNET#0") 以应用标准发布门户网站定义后,我正在尝试基于带有 TOC 页面布局的欢迎页面创建一个新页面。

但是,当我调用这段代码时出现异常

Dim pubSite As New PublishingSite(_siteColl)
Dim pubWeb As PublishingWeb = PublishingWeb.GetPublishingWeb(site)

Dim layouts() As PageLayout = Nothing
layouts = pubWeb.GetAvailablePageLayouts(_welcomeContentTypeID)

GetAvailablePageLayouts 方法调用引发以下异常。

无效的字段名称。{7581e709-5d87-42e7-9fe6-698ef5e86dd3}

这仅发生在我们的现场农场。它没有发生在开发或测试环境中,所以我希望这是一个配置更改,但我可以在 Tinterweb(原文如此)上找到的所有引用都与缺少字段类型“PublishingHidden”有关,但我怎样才能恢复这个鉴于这是在网站集配置过程中发生的?

谢谢

查理

4

2 回答 2

0

您可能需要检查您的代码并确保您没有通过显示名称访问该字段...

fieldName = web.lists[mylist].Fields["FieldName"].InternalName

于 2009-10-25T02:55:28.347 回答
0

在执行此操作之前是否已激活所有必需的功能(发布基础设施等)?使用类似下面的东西:

// Check if the 'Publishing Prerequisites' feature is at the web and activated
var pubprereqguid = new Guid("A392DA98-270B-4e85-9769-04C0FDE267AA");
if (site.Features[pubprereqguid] == null)
{
  site.Features.Add(pubprereqguid);
}

// Check if the 'Publishing Resources' feature is at the web and activated
var pubresguid = new Guid("AEBC918D-B20F-4a11-A1DB-9ED84D79C87E");
if (site.Features[pubresguid] == null)
{
  site.Features.Add(pubresguid);
}
于 2009-10-25T01:14:22.623 回答