Forum Discussion

tejaswini1010's avatar
tejaswini1010
Copper Contributor
Dec 20, 2019

how to solve Microsoft client property or field   not initialized  exception ?

hi,

 

I  want to retrive sharepoint list data into  c#.net Project.

I have used Microsoft sharepoint client object model.

But,It gives Microsoft client property or field   not initialized  exception ?

How do i get sharepoint list data  in c#.project?

 

 

 

 

  • tejaswini1010's avatar
    tejaswini1010
    Copper Contributor
    SecureString theSecureString = new NetworkCredential("", "ASDFGHHcxv").SecurePassword;

    //SecureString password = abc;
    string userName = "Txcvci@indica.onmicrosoft.com";
    var ctx = new ClientContext("https://indica.sharepoint.com/sites/Testtej2");
    ctx.Credentials = new SharePointOnlineCredentials(userName, theSecureString);

    ctx.Load(ctx.Web.Lists);
    ctx.ExecuteQuery();

    foreach (var list in ctx.Web.Lists)
    {
    //if (list.BaseTemplate == 101)
    {
    Console.WriteLine(list.BaseTemplate);
    Console.WriteLine("List Title: {0}", list.Title);
    }
    }


    }

Resources