SharePoint Namespace

I want to program sharepoint lists but when I try to add a reference to "Microsoft.SharePoint" to access the namespace, I don't see it.

How can I tell if it's there or not?


Here's the error I get for below:

The type or namespace name 'SPSite' could not be found (are you missing a using directive or an assembly reference?
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class _Default : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)

    protected void submit_Click(object sender, EventArgs e)
        //String parameters to enable site and list access
        const string siteUrl = "";
        const string siteName = "/Lists/Parts/";
        const string listName = "Parts";

        //Return a site collection using the SPSite constructor providing the site URL
        SPSite siteCollection = new SPSite(siteUrl);

        //Return the target web site based on site name
        SPWeb site = siteCollection.AllWebs[siteName];

        //Return a collection of list items based on the Items property
        //for the specific named list
        SPListItemCollection listItems = site.Lists[listName].Items;

        //Add a list item to the list items collection
        SPListItem item = listItems.Add();

        //Populate item data via user indexers with form input data
        item["Title"] = title.Text;
        item["Part Number"] = Convert.ToInt16(partNum.Text);
        item["Price"] = Convert.ToInt16(price.Text);

        //Update SP database with changes made to this item

        //UI clean-up
        Label1.Text = "Done!";


Open in new window

IsaacSharePoint Client Side DeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Are you doing this on the SharePoint Server itself? You need to.
Hi Thelnnovator,

Have you added the Sharepoint dll using Add Reference -> Microsoft.Sharepoint.

If not you have to do it and then

you have to add using MIcrosoft.Sharepoint at the top once addding the Sharepoint dll reference.

Hope this would solve your problem.
IsaacSharePoint Client Side DeveloperAuthor Commented:
Yes, I'm doing this on the SharePoint Server.

I tried to add the Sharepoint dll using Add Reference -> Microsoft.Sharepoint but it did not show it in the listing of dll's.

IT Pros Agree: AI and Machine Learning Key

We’d all like to think our company’s data is well protected, but when you ask IT professionals they admit the data probably is not as safe as it could be.

Here you go:

Setting a Reference to the Microsoft.SharePoint Assembly
After creating a project, add a reference to the Microsoft.SharePoint assembly to import its namespaces and implement IntelliSense features in the Object Browser and Code Editor.

To add a reference to the Microsoft.SharePoint assembly

In Solution Explorer, right-click the project, and then click Add Reference on the shortcut menu.

On the .NET tab of the Add Reference dialog box, select Windows SharePoint Services in the list of components, and then click OK.

To run or debug code that uses the Microsoft.SharePoint assembly, you must run the code on the server running Windows SharePoint Services. If you are using Visual Studio 2005 on a remote computer, you cannot run or debug code that uses the object model. However, you can set a remote reference to the assembly to write code and see the Microsoft.SharePoint assembly represented in the Code Editor. To add a remote reference in this way, do the following:

Click the Browse tab of the Add Reference dialog box and navigate to Microsoft.SharePoint.dll in the \\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\ISAPI folder on the server running Windows SharePoint Services. You may instead want to copy Microsoft.SharePoint.dll from this folder to a local drive on the remote computer, and then open this local copy of the DLL. Click Open.
IsaacSharePoint Client Side DeveloperAuthor Commented:
I successfully added Windows SharePoint Services.
How do I call it using the "Using"? Thanks.
using Microsoft.SharePoint;

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
the answer given by me is also the same.
Why have the author not accepted it???

i would have earned 500 points
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SharePoint

From novice to tech pro — start learning today.