I am getting what I think is a bogus "File Not Found" error when I do simple SharePoint 2010 client coding. It is not that I'm building to the wrong CPU type or the wrong .NET version. (I'm building to "any CPU" or "x64" and .NET 3.5.) I copied the Microsoft.SharePoint*.dlls from the server and put them in C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI. (I've tried other folders too.) I then opened my Visual Studio 2010 project, right-clicked on References, clicked the Browse tab and added one or all of the dlls (I should only need Microsoft.SharePoint.dll.) This is the simple program I try to run:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
namespace SPListsToConsole {
class Program {
static void Main( string[] args ) {
using ( SPSite sc = new SPSite( "http://orsandbox01/SitePages/Home.aspx" ) ) {
SPWeb site = sc.RootWeb;
foreach ( SPList list in site.Lists ) {
if ( !list.Hidden ) {
Console.WriteLine( list.Title );
}
}
}
}
}
}
And here is the error I get:
Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.SharePoint.Library, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies. The system cannot find the file specified. File name: 'Microsoft.SharePoint.Library, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' at SPListsToConsole.Program.Main(String[] args) WRN: Assembly binding logging is turned OFF. To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. Note: There is some performance penalty associated with assembly bind failure logging. To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
I haven't done any SharePoint coding before but I've following all the instructions I can Google. TIA for any help you can share.