我继承了SharePoint 2007网站,我正在努力将其迁移到SharePoint 2010.我正在使用2010 .DLL重新编译功能接收器,我遇到了以下错误:
'Microsoft.SharePoint.Publishing.PublishingWeb'不包含'CurrentNavigationNodes'的定义,并且没有扩展方法'CurrentNavigationNodes'接受第一个类型为'Microsoft.SharePoint.Publishing.PublishingWeb'的参数可以找到(你是否遗漏了) using指令或程序集引用?)
在Sharepoint 2007中,CurrentNavigationNodes是Microsoft.SharePoint.Publishing.PublishingWeb的一个属性。显然,它被转移到另一个类,或者被另一个获取节点列表的方式完全替换。我无法弄清楚。任何人都知道这样做的新方法是什么?
以下是2007年代码的相关内容:
// set references to site, web, publishing site, publishing web
SPWeb thisWeb = (SPWeb)properties.Feature.Parent;
SPSite thisSite = thisWeb.Site;
PublishingSite thisPubSite = new PublishingSite(thisSite);
PublishingWeb thisPubWeb = PublishingWeb.GetPublishingWeb(thisWeb);
// enable tree view
thisWeb.TreeViewEnabled = true;
thisWeb.Update();
// navigation settings
thisPubWeb.InheritGlobalNavigation = true;
thisPubWeb.InheritCurrentNavigation = false;
thisPubWeb.IncludePagesInNavigation = true;
thisPubWeb.IncludeSubSitesInNavigation = true;
thisPubWeb.NavigationShowSiblings = false;
// clear current navigation (thrice needed to get everything)
SPNavigationNodeCollection navNodes = thisPubWeb.CurrentNavigationNodes;
foreach (SPNavigationNode thisNavNode in navNodes)
{
navNodes.Delete(thisNavNode);
}
foreach (SPNavigationNode thisNavNode in navNodes)
{
navNodes.Delete(thisNavNode);
}
foreach (SPNavigationNode thisNavNode in navNodes)
{
navNodes.Delete(thisNavNode);
}
thisPubWeb.Update();
答案 0 :(得分:0)
问题解决了。看来,由于PublishingWeb扩展了SPWeb,微软从PublishingWeb中删除了CurrentNavigationNodes,转而使用SPWeb.Navigation.CurrentNavigationNodes。