Creating a SharePoint Object Model Script in Visual Studio

Object model scripts are scripts that access the SharePoint API directly.  These scripts are typically written in Visual Studio and are run while on-server and are great to automate tasks or to complete operations that you can’t run using stsadm or the central admin console.  The below demonstration shows hot to create a simple project that consumes the object model to modify the publishing polling interval.

Step 1

Open Visual Studio 2005 or 2008 and create a new project.

clip_image001

Step 2

Add a reference to the Microsoft.SharePoint.dll and, for the sake of this example Microsoft.SharePoint.Publishing.dll. Keep in mind this is a "partial" DLL so you’ll want to put most of the SharePoint DLLs that you download from your server into a folder such as Third Party. If your development environment has a SharePoint server running then simply reference the DLLs in C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\ISAPI , also note that the Publishing feature is not installed into the web server extensions folder, instead it resides in C:\Program Files\Microsoft Office Servers\12.0\Bin.

clip_image002

Step 3

Enter code of Form1 and add the using statement for "Microsoft.SharePoint.Administration".

clip_image003

Step 4

Build out your form or command line switches

clip_image004

Step 5

Code up your action by using the config portion of the SharePoint object model as follows

clip_image005

VN:F [1.8.1_1037]
Rating: 0.0/10 (0 votes cast)
VN:F [1.8.1_1037]
Rating: 0 (from 0 votes)

Popularity: 2% [?]

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
Share this Post:
Digg Google Bookmarks reddit Mixx StumbleUpon Technorati Yahoo! Buzz DesignFloat Delicious BlinkList Furl

No Responses to “Creating a SharePoint Object Model Script in Visual Studio”

Leave a Reply:

Name (required):
Mail (will not be published) (required):
Website:
Comment (required):
XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Powered by eShop v.4