SharePoint 2013 and newer versions are 64-bit only and so the assembly/program needs to be also built for 64-bit processor.
Right after your project is created it is necessary to swich the Platform target from Any CPU to x64 otherwise error will occure.
using System;
using Microsoft.SharePoint;
namespace StackOverflow
{
class Samples
{
static void Main()
{
using (SPSite site = new SPSite("http://server/sites/siteCollection"))
using (SPWeb web = site.OpenWeb())
{
Console.WriteLine("Title: {0} Description: {1}", web.Title, web.Description);
}
}
}
}