通过c#控制台应用程序验证sharepoint用户登录时出错
我在通过c#控制台应用程序验证共享点的用户凭据时出错 我正在尝试下面的代码进行身份验证通过c#控制台应用程序验证sharepoint用户登录时出错,c#,sharepoint,sharepoint-2010,sharepoint-2013,C#,Sharepoint,Sharepoint 2010,Sharepoint 2013,我在通过c#控制台应用程序验证共享点的用户凭据时出错 我正在尝试下面的代码进行身份验证 using (ClientContext ctx = new ClientContext("https://sharepointurl")) { ctx.Credentials = new NetworkCredential(@"username", "password", "domain");
using (ClientContext ctx = new ClientContext("https://sharepointurl"))
{
ctx.Credentials = new NetworkCredential(@"username", "password", "domain");
// Get the SharePoint web
Web web = ctx.Web;
// Load the Web properties
ctx.Load(web);
}
但是在第二行ctx.Credentials
中,我得到了一个错误-
ServerVersion='ctx.ServerVersion'引发了类型为的异常
'Microsoft.SharePoint.Client.PropertyOrFieldNotInitializedException'
我已经添加了dll
referenceofMicrosoft.SharePoint
和Microsoft.SharePoint.RunTime
版本16.0.0.0
,并且还通过15.0.0.0
知道问题出在哪里吗?在用户名之前删除@。并且不要忘记加载()后的ctx.ExecuteQuery()
您应该(正如@vinayak hegde所提到的)添加Microsoft.SharePoint.Client/.Client.Runtime DLL。Microsoft.SharePoint.dll用于服务器。在ClientContext中运行,为什么需要Microsoft.SharePoint和Microsoft.SharePoint.RunTime,请参考Microsoft.SharePoint。Client@vinayakhegde是,它的Microsoft.SharePoint.Client继承自Microsoft.SharePoint