When I feel like to act together with SharePoint site to obtain data, quickly I will create a console application project to interact with SharePoint site instead of creating standard/visual webpart or custom solution
I am fond of console applications since there is no need of packaging the custom solution, deploying, activating etc. Just write the code and hit F5, if it run…runs, if not throws the error right away 🙂
As I am comfortable with console applications in the same passion today I have created one console application project on SharePoint 2010 server and tried to list subsites from a site, the code be incredibly straightforward with not many lines, as soon as I hit F5 it thrown an error message saying that
FileNotFoundException was unhandled
The Web application at http://fivenumber:5 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.
The same code executes on MOSS 2007 server with out any problem.
I had Bing for a moment finally dig up the resolution, as there is hardware difference, between MOSS 2007 and SharePoint 2010.
Console applications by default targeted to x86 platform, therefore comprise to change the console application project properties to x64 or Any CPU
To resolve, right click on project and select Properties
Click on Build tab, under Platform target section select the option x64 or Any CPU then save the changes and run the code once again
Keep coding, Good Luck 🙂