Thursday, July 1, 2010

Visual Studio 2010 cannot find SharePoint 2010 site

I realize I haven't blogged in a while, but hopefully I should be back on here blogging about all the stuff I am doing in SharePoint 2010. It's a great platform, and I have been working on it for a few months.

So here is the scenario:
You are using Windows 7 x64 bit and have installed SharePoint 2010 on it. You are building great solutions in VS 2010 for SharePoint 2010. You spin up a quick Console Application to try some stuff out against your local instance of SharePoint and your program throws up an error at this line, indicating that the site cannot be found.

using (SPSite site = new SPSite([your local URL]))

This happens because Visual Studio is configured to build for x86 by default. To get past this error, right click on the solution file in Visual Studio --> click on properties, on the top right click on Configuration manager and add a x64 configuration. Then go to project properties --> Build --> Select x64 as the target platform.

Voila, that should all work now.

No comments: