2017-02-07 8 views
0

c#consoleアプリケーションで共有ポイントのユーザー資格情報の認証にエラーが発生しました。C#Consoleのアプリケーションで共有ポイントのユーザーログインを認証する際にエラーが発生しました

私はその認証のために以下のコードを試しています。

 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 2行目に、私はエラーになっています -

がServerVersion = 'ctx.ServerVersionは' 'Microsoft.SharePoint.Client.PropertyOrFieldNotInitializedException'

をタイプ の例外を投げました

dllMicrosoft.SharePointおよびMicrosoft.SharePoint.RunTimeバージョン16.0.0.0の参照番号を追加しました。また、15.0.0.0

何が問題になるはずですか?

+0

ClientContextで実行すると、なぜMicrosoft.SharePointとMicrosoft.SharePoint.RunTimeが必要ですか?RefはMicrosoft.SharePoint.Clientである必要があります –

+0

@vinayakhegdeはいMicrosoft.SharePointから継承されたMicrosoft.SharePoint.Client – Shirish

答えて

0

ユーザー名の前に@を削除してください。また、Load()の後にctx.ExecuteQuery()を忘れないでください。

そして、Microsoft.SharePoint.Client/.Client.Runtime dllを追加する必要があります(@vayayak hegdeが述べたように)。 Microsoft.SharePoint.dllはサーバー用です。

関連する問題