2010-02-09

Console Application, SharePoint 2010, accessing SPSite, and FileNotFoundException

When you try to open a site collection using new SPSite("") in e.g. a Console Application you get a FileNotFoundException - "The Web application at http://sharepoint2010/sites/development could not be found. Verify that you have typed the URL correctly. If the URL should be serving existing content, the system administrator may need to add a new request URL mapping to the intended application."

Then the first thing to check is that the Build Platform target is set to x64.

If that doesn't do it for you, thenn hopefully Google will find the anser for you.

4 comments:

Anonymous said...

"Hopefully Google will" indeed, because Microsoft sure isn't going to.

Márton said...

THX :)

Joseph Fluckiger said...

That fixed it, thanks!

Petri Malherbe said...

•Goto project properties of console app.
•Click Builds tab
•Change the Target Platform to "Any CPU"
•And you should get your SPSite object instantiated successfully.