Through my discussions with developers and attendees in SharePoint Events, I was getting a lot of questions about the target .net framework for applications and solutions that are built against Server and Client Object Model in SharePoint 2010.
I decided to list the things you need to take care and set before start compiling and deploying your solutions and getting runtime errors using SharePoint object model.
1) If you are developing a SharePoint 2010 Solutions. You solution has to target .NET Framework 3.5 Only and Not 4.0.
2) Also, if you build your solutions as layers and you have different projects ( Non SharePoint Project) all are used within your SharePoint project, ALL OF THEM HAVE TO TARGET .NET FRAMEWORK 3.5 as well.
3) Your target CPU platform can’t be x86. Even if you are building a console application using the client object model. The Solution ? Next Point.
4) It’s recommended that all your projects to target Any CPU platform, You can’t have some projects are targeting x86 ( Such as Console Application ) that are referencing x64 CPU platform.
5) You have the option “Less Recommended” to target all your project to x64. but in this case your solution will not be able to run on x86 machines. Instead, Select Any CPU platform as recommended on Point 4.
6) If you made all your projects to target Any CPU, the only point you have to put in your consideration is the file size for your solution will be bigger than if you target x64 CPU platform.
7) If you decided to enable x64 configuration, here is the steps you need to do in VS 2010 and the resource of this post:
Hope this helps.