Sharepoint在线中的StackOverflow异常

问题描述 投票:0回答:1

我正在尝试使用多个线程在共享点在线中添加新的列值。但是我得到一个stackoverflow异常。你能帮我么。这是我的代码:

try
{
    foreach (Microsoft.SharePoint.Client.ListItem item in listCol)
    {
        if (item.FileSystemObjectType == FileSystemObjectType.File)
        {
            if (!item["FileLeafRef"].ToString().Contains(".tmd"))
            {

                item[propertyName] = propertyValue;  // this line is cause of error
                item.Update();                       // this line is cause of error                     
            }
        }
    }
    ExecuteQueryWithRetry(clientContext);
}
catch (StackOverflowException ex)
{
    Logger.LogException(ex, "Adding Values", "CMM " + "Adding Values");
}
c# sharepoint sharepoint-2013 sharepoint-online
1个回答
0
投票

我测试了下面的代码片段,以更新文件项的Title属性,并按预期工作:

            using (ClientContext ctx = new ClientContext("https://tenant.sharepoint.com/sites/dev/"))
            {

                ctx.Credentials = new SharePointOnlineCredentials(account, secret);
                ctx.Load(ctx.Web);
                ctx.ExecuteQuery();

                List targetList = ctx.Web.Lists.GetByTitle("Documents");
                ListItemCollection ItemCol = targetList.GetItems(CamlQuery.CreateAllItemsQuery());
                ctx.Load(ItemCol);
                ctx.ExecuteQuery();
                foreach (Microsoft.SharePoint.Client.ListItem item in ItemCol)
                {
                    if (item.FileSystemObjectType == FileSystemObjectType.File)
                    {
                        if (!item["FileLeafRef"].ToString().Contains(".tmd"))
                        {

                            item["Title"] = "TestTitle";  
                            item.Update();                       

                        }
                    }
                    ctx.ExecuteQuery();
                }
             }
© www.soinside.com 2019 - 2024. All rights reserved.