c# - C#如何使用反射调用clientContext.Web.Lists.GetByTitle(documentLibrary)?
问题描述
我是 C# 新手,我想知道如何通过反射调用下面的代码。
ClientContext clientContext = new ClientContext(siteURL);
List documentList = clientContext.Web.Lists.GetByTitle(documentLibrary);
它依赖于Microsoft.SharePoint.Client.dll
和Microsoft.SharePoint.Client.Runtime.dll
。
我能够创建 clientContext 对象。但是,我无法调用另一部分,即,
Web.Lists.GetByTitle(documentLibrary);
下面是我创建clientContext的代码。
Type clinetContext = null;
foreach (Type type in sharePointClientTypes)
if (type.FullName.Equals("Microsoft.SharePoint.Client.ClientContext"))
{
clinetContext = type;
break;
}
ConstructorInfo constructorInfo = clinetContext.GetConstructor(new[] { typeof(string) });
object context = constructorInfo.Invoke(new string[] { siteURL });
谁能帮我!!
解决方案
试试用这个
Web web = clinetContext.Web;
clinetContext.Load(web);
web.Context.ExecuteQuery();
List documentsList = web.Lists.GetByTitle(documentLibrary);
clinetContext.Load(documentsList);
web.Context.ExecuteQuery();
推荐阅读
- python - 多列绘图Python
- javascript - Openlayers 地图图块最初未在单页应用程序中加载
- javascript - 如何确保始终显示至少一个 DIV?
- javascript - 转换字符串值的Javascript方法
- google-analytics - 如何从服务器使用 Google 跟踪代码管理器设置分析变量?
- swift - 为什么这段 Swift 代码编译和运行没有错误?
- sas - 宏中的 SAS 宏
- matlab - Matlab没有接收到键盘输入
- algorithm - 如何确定此解决方案重复排列的运行时间?
- python - Python3:从 2.7 转换后使用 ttk?