If you are using SharePoint Server 2007 to build a console application, you would do something like this:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
namespace ConsoleApplication
{
class Program
{
static void Main(string[] args)
{
using (SPSite spSite = new SPSite("http://demo2010a"))
{
using (SPWeb spWeb = spSite.RootWeb)
{
Console.WriteLine(spWeb.Title);
}
}
Console.WriteLine("Done!");
}
}
}
If you take the same code, execute it against SharePoint 2010, you will be surprised (at least for the first time) to see VS2010 throw an error!
There is nothing wrong with your code, except that now SharePoint 2010 is 64bit!
You got it right, your SharePoint Server 2007 console application’s target platform would have been x86(32 bit) and you need to change that to x64(64 bit) in the Build configuration of your project.
The other thing to make sure is that the target framework is .NET 3.5.