Thursday, September 23, 2010

A Visual Studio 2010 Beta Console Application issue in SharePoint 2010 custom code

If you create a console application in Visual Studio 2010 and try to use types such as SPSite from the SharePoint server object model (Microsoft.SharePoint.dll assembly), when you compile your project, you'll get the following error:




You won't get this error if you're using types such as Site from the SharePoint client object model (Microsoft.SharePoint.Client.dll assembly) in your console application.

As you can see from the previous snapshot, Visual Studio 2010 complains that it couldn't find the Web application even though the Web application exists in reality. This happens because of two reasons. First, the active solution platform by default is set to x86:



You need to change that to x64. Pretty easy to do this. Just select New from the drop down menu:


This launches the New Solution Platform dialog. Select x64 and click OK.


After you did that you should see that the right active solution platform shows up:


Second, Visual Studio 2010 by default uses the .NET Framework 4.0. You need to change that to .NET Framework 3.5. To do that, right click the project node in the solution explorer window and select Properties. You should see a drop down menu there for the target framework. Select .NET Framework 3.5 from that menu and save your changes.

Happy Coding!

No comments:

Post a Comment