spfarm.local对象在SharePoint 2013中缓存
-
10-12-2019 - |
题
我正在遇到一个奇怪的问题,其中spfarm.local对象没有为SharePoint 2013更新,但它为2010年进行了。基本上我有一些代码在C#中添加/部署/更新SharePoint解决方案。我有线程等待,直到添加解决方案和/或部署作业在继续之前完成。
这是代码的简化版本:
var complete = false;
while (!complete)
{
complete = SPFarm.Local.Solutions[“solutionName.wsp”] != null;
if (!complete)
Thread.Sleep(10000);
}
.
在SharePoint 2010中,这完美有效。但是,2013年,解决方案持续返回NULL。我可以验证解决方案是否存在于具有Get-Spsolution的单独的PowerShell窗口中,但在此帖子中未更新。
关于如何获取SharePoint 2013以更新主线程中的Spfarm.local对象的任何想法?
解决方案
SP.Update()
should work after you add the solution to the farm.
var complete = false;
while (!complete)
{
complete = SPFarm.Local.Solutions[“solutionName.wsp”] != null;
if (!complete){
SPFarm.Local.Update();
Thread.Sleep(10000);
}
}