Monday, June 6, 2011

FileNotFoundException with new SPSite

When debugging a SharePoint console application in Visual Studio 2010, I ran into the error FileNotFoundException during the line:

using (SPSite site = new SPSite("http://dev.company.com/mysite/"))

The fix that worked for me was to make sure the Platform target: on the Build tab under the Project's properties page, was set to Any CPU from x86 which makes sense since SharePoint binaries are targeted to the x64 CPU.
The FileNotFoundException error is a little misleading, so if you run into, please check your Platform target.

No comments:

Post a Comment