Showing posts with label FileNotFound. Show all posts
Showing posts with label FileNotFound. Show all posts

Friday 13 August 2010

SharePoint 2010 console application System.IO.FileNotFound error

Problem: Built a local console app to access a SharePoint site, add System.Web & Microsoft.SharePoint references to the console project.  Run the code and get a System.IO.FileNotFound error.
Code SPSite site = new SPSite(http://demo1);
Hypothesis: Check url is correct (it was).  VS2010 console apps are set to be x86 by default.  SharEPoint only works on x64 so Microsoft.SharePoint is x64. 
Resolution:  Open VS2010, right click the console project.  "Properties" > "Build" tab, set "Platform target to "x64".
Tip: Uses the .NET 3.5 for console applications.
More info:  Top 2 search on Google yielded the solution.  Console FileNotFound error. and 2nd solution System.IO.FileNotFound Error