c# - Sharepoint 中的 StackOverflow 异常在线
问题描述
我正在尝试使用多个线程在线共享点中添加新列值。但我得到一个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");
}
解决方案
我测试了下面的代码片段来更新我身边的文件项的 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();
}
}
推荐阅读
- javascript - 如何索引firebase中的引用字段?
- sql - SSIS 多播 - 按特定顺序执行
- javascript - 将参数传递给 React (API) 中的函数
- javascript - 如何使用 ComponentDidUpdate?
- oracle - Oracle 在创建存储过程时出错。ORA-22905: 无法访问非嵌套表项中的行
- javascript - 在使用Javascript向表中添加行的函数中添加on-change
- flutter - 在颤动中将小部件对齐到屏幕的左侧和右侧
- sql - sql查询异常
- python - 填充pyspark数据框空值
- python - 为什么keras模型不能在python的多进程池中运行?