FileNotFound exception opening SPSite in Visual Studio 2010 using SharePoint 2010

To my surprise, I received a FileNotFound exception while trying to do the following in a console application:

using(SPSite site = new SPSite(“http://computername:6789”))



I just installed Visual Studio 2010 and SharePoint 2010 and wanted to test out some code using a console application.

To address this issue, I did the following:

In Visual Studio, go to Solution Explorer -> Go to the Project (csproj file)  -> Right (or left depending on your mouse click setup) click and select Properties

Go to the Build tab -> on the Target Platform drop down list, select Any CPU.

Save and rebuild project

Run project.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: