ApplyingProvisioningTemplate时找不到方法ExecuteQueryAsync

时间:2018-08-29 04:10:10

标签: sharepoint sharepoint-online csom

所以我在这里遵循了教程 https://docs.microsoft.com/en-us/sharepoint/dev/solution-guidance/introducing-the-pnp-provisioning-engine,但我遇到了这个问题

找不到方法:“ System.Threading.Tasks.Task Microsoft.SharePoint.Client.ClientRuntimeContext.ExecuteQueryAsync()”

这是我的代码

private static void ApplyProvisioningTemplate(string targetWebUrl, string userName, SecureString pwd)
{
    using (var context = new ClientContext(targetWebUrl))
    {
        context.Credentials = new SharePointOnlineCredentials(userName, pwd);
        Web web = context.Web;
        context.Load(web, w => w.Title);
        context.ExecuteQueryRetry();

        // Configure the XML file system provider
        XMLTemplateProvider provider = new XMLFileSystemTemplateProvider(String.Format(@"C:\temp\pnpprovisioningdemo"),"");

        // Load the template from the XML stored copy
        ProvisioningTemplate template = provider.GetTemplate("PnPProvisioningDemo.xml");

        // We can also use Apply-SPOProvisioningTemplate
        web.ApplyProvisioningTemplate(template);

    }
}

context.ExecuteQueryRetry();中发生错误 知道我在做什么错吗?

1 个答案:

答案 0 :(得分:0)

ClientContext类中有ExecuteQueryAsync():

ClientContext class screenshots

也许方法错误,请用context.ExecuteQueryRetry ()下面的代码替换上下文:

context.ExecuteQueryAsync();