我正在尝试在控制台应用程序中使用 c# 创建新的结果源并且每次都会出错,我成功更新了现有的结果源但无法创建新的结果源,这是我的代码:
using (SPSite oSPsite = new SPSite("http://XXXXXXX/sites/SearchAdministration"))
{
Microsoft.SharePoint.SPServiceContext context = SPServiceContext.GetContext(oSPsite);
// Get the search service application proxy
SearchServiceApplicationProxy searchProxy = context.GetDefaultProxy(typeof(SearchServiceApplicationProxy)) as SearchServiceApplicationProxy;
// Get the search service application info object so we can find the Id of our Search Service App
SearchServiceApplicationInfo ssai = searchProxy.GetSearchServiceApplicationInfo();
// Get the application itself
SearchServiceApplication application = Microsoft.Office.Server.Search.Administration.SearchService.Service.SearchApplications.GetValue<SearchServiceApplication>(ssai.SearchServiceApplicationId);
FederationManager fedManager = new FederationManager(application);
SearchObjectOwner owner = new SearchObjectOwner(SearchObjectLevel.SPSite, oSPsite.RootWeb);
Source currentResultSource = fedManager.CreateSource(owner);
currentResultSource.Commit();
}
错误在提交函数中-“您尝试的操作违反了对象之间的强制依赖关系,例如依赖于不存在的对象或删除其他对象依赖的对象。” 我注意到在创建结果源之后,currentResultSource.id 全为零