Search code examples
c#sharepointdllsharepoint-2010sharepoint-clientobject

Cannot Refer to Microsoft.SharePoint.Client.dll


I am creating a Windows application the will access a sharepoint website. There for I need to use Microsoft.SharePoint.Client.dll and Microsoft.SharePoint.Client.runtime.dll in project.

I have add them in my references but cannot use it. Can someone help me?

Please see the issue here: Issue

using Microsoft.SharePoint.Client;

namespace WpfApplication3
{
 public partial class MainWindow : Window
 {
    public MainWindow()
    {
        ClientContext context = new ClientContext("http://hp");
        InitializeComponent();
    }
 }
}

Solution

  • The bottom of your screenshot tells you explicitly what is wrong. You seem to be targeting .NET 4.0 Client Profile which does not contain a reference for System.Web which is a dependency of the SharePoint Client.

    Re-target your project for .NET 4.0.

    If you're using Visual Studio go to Project > Properties > Application > Target Framework > Change it to 4.0 (NOT Client Profile)

    enter image description here