When I started working with SPS 2010 APIs I got a mysterious but common error in my Visual Studio 2010 RC. I was working with a .NET console based application. As normal I have double checked the URL, user permission, and even tried to create the SPSite instance with the IP address (eg: http://126.96.36.199) but I didn’t get any clue about this error.
Later, I came to know that once we start developing any .NET stand alone (windows based apps, console based apps) or web applications in Visual Studio 2010, the default build platform of the solution will be set to x86, and that was the reason I was getting that exception. Once I changed the target build platform to “Any CPU” issue got resolved !
1. Right click on the solution inside the solution explorer and select the “Configuration Manager”
2. Create a new active solution platform and select it as “Any CPU”, after that rebuild your application and you are
good to go.