BlogPost

Creating a SharePoint list via a Console Application

Creating a SharePoint list via a Console Application



This month I thought I would document the process of creating a list through a console application in Visual Studio, In this post we create a Todo List with site columns and add them to the default view.


Step One

  • Create a new Console Application project in visual studio - call it what you like...

Step Two

  • Once the project is created right click on references and Add Reference

Step Three

  • We need to find and select the Microsoft.SharePoint.dll

Step Four

  • Create a new Empty SharePoint Project
  • Add the Using Microsoft.SharePoint;

Step Five

  • Now if we run this application it will fail…

Step Six

  • So we need so we need to right click on the project name and go to Properties, click on build and then change the platform target to x64 from any CPU

Step Seven

  • Now in the program type out the following code, you can just add the body of the code block into the main method but I like to section my methods out, up to you…

Step Eight

  • Build the solution and then run it.
  • You should see a Command prompt box appear while the application is running you could add Console.Writeline or ReadLine to prompt once done, otherwise it will disappear and completed

    Now go to your site contents within your SharePoint Environment

    And you should see your new todo list